Saturday, September 25, 2010

How to send an email using asp.net (HTML formatted)

using System.Net.Mail;
Example:
try
{
    string messageHtml = @"
        <h1>Hello</h1>
        <p>Your account has been created</p>
        <a href=""http://www.compnay.com?confirm.aspx?guid=1234"">Click here to confirm your email</a>
    ";       
    MailMessage message = new MailMessage("from@company.com""to@company.com");
    message.IsBodyHtml = true;
    message.Body = messageHtml;
    message.Subject = "Hi there";
    SmtpClient smtpClient = new SmtpClient("auth.smtp.company.com");
    smtpClient.Send(message);
    this.Response.Redirect("Contact.aspx?action=MessageSent");
}
catch
{
    throw new InvalidOperationException("Unable to send an email");
}

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...