Email

  • Thread starter Thread starter JMMB
  • Start date Start date
J

JMMB

what would be the best technology to send emails in a ASP.NET Application?
I used to use CDONTS with ASP.

thanks,
 
Well, here is the lazy answer (this is what I ended up doing). Include
CDONTS (the COM object) in your references.. and use it like this:

CDONTS.NewMailClass objMail = new CDONTS.NewMailClass();
string SendFrom = Request.Form["From"] + " <" + Request.Form["FromEmail"] +
">";
string SendTo ="Frank Drebin <[email protected]>";
string From = Request.Form["From"];
string FromEmail = Request.Form["FromEmail"];
string Subject = Request.Form["Subject"];
string Msg = Request.Form["Msg"].Replace("\n","<br>"); // Replace carriage
returns with line breaks
string BodyText = "";
BodyText += "<STYLE> .MsgTxt { font-family:Verdana, Arial; font-size: 10pt;
font-style: normal; line-height: normal;font-weight: normal} </STYLE>";
BodyText += "<ul>";
BodyText += "<table width=\"100%\">\n";
BodyText += "<tr><td class=MsgTxt>From:</td><td class=MsgTxt><b>" + From + "
(<a href=mailto:" + FromEmail + ">" + FromEmail + "</a>)</b></td>\n";
BodyText += "<tr><td class=MsgTxt>Sent:</td><td class=MsgTxt><b>" +
DateTime.Now.ToString() + "</b></td>\n";
BodyText += "<tr><td class=MsgTxt>Subject:</td><td class=MsgTxt><b>" +
Subject + "</b></td>\n";
BodyText += "</table><hr>\n";
BodyText += Msg + '\n';
BodyText += "-----\n";
BodyText += "</ul>";
objMail.BodyFormat = 0;
objMail.MailFormat = 0;
objMail.Send(SendFrom,SendTo, Subject, BodyText, 1);
 
Back
Top