Pages

Subscribe:

Tuesday, 18 February 2014

How to send mail

using System.Net.Mail;

private void SendMail()
    {
        MailMessage oMail = new MailMessage();
        oMail.To.Add("ToEmail");
        MailAddress oAddress = new MailAddress("FromEmail");
        oMail.IsBodyHtml = true;
        oMail.From = oAddress;
        oMail.Priority = MailPriority.Normal;
        oMail.Subject = "";
        sBody = "<html><body></body></html>";
        oMail.Body = sBody;
        SmtpClient oSmtp = new SmtpClient();
        oSmtp.Send(oMail);
   }

in web.config

<system.net>
        <mailSettings>
            <smtp>
                <network host="" userName="" password="" defaultCredentials="false" port=""/>
            </smtp>
        </mailSettings>
    </system.net>

0 comments:

Post a Comment