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:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...