The validation problem is solved by setting the Page attribute Validation="false". But then when I sent the HTML it was received as text.
The solution is to use IsHTML=true In my example, I used a check box:
protected void btnSend_Click(object sender, EventArgs e)
{
string sTo = "jane@foo.com";
string sFrom = ddlFrom.SelectedItem.Text.Trim();
string sSubject = txtSubject.Text.Trim();
string sBody = txtContent.Text.Trim();
lblStatus.Text = "Sending... please wait";
MailMessage msg = new MailMessage(sFrom, sTo, sSubject, sBody);
msg.IsBodyHtml = chkIsHTML.Checked;
SmtpClient mailObj = new SmtpClient("localHost");
mailObj.Credentials = new NetworkCredential("username", "password");
mailObj.Send(msg);
clearTexts();
lblStatus.Text = "Success: Sent message to Jane at " + DateTime.Now.ToLongTimeString() + " Eastern.";
}
References: http://www.hintsandtips.com/ShowPost/131/hat.aspx
http://aspnet.4guysfromrolla.com/articles/080206-1.aspx
No comments:
Post a Comment