C# send mail by smtp with html body. (add reference System.Net)
using System.Net.Mail;
public static void Sendalertmail(string SendToList, string MailSubJect, string MailBody)
{
string fromEmail = "Administrator@test.com";//sending email from...
string ToEmail = SendToList; //destination email
string body = MailBody;
string subject = MailSubJect;
try
{
MailMessage mm = new MailMessage(fromEmail, ToEmail);
mm.Subject = MailSubJect;
mm.Body = MailBody;
mm.IsBodyHtml = true;
SmtpClient sMail = new SmtpClient("192.168.1.1");//exchange or smtp server goes here.
sMail.DeliveryMethod = SmtpDeliveryMethod.Network;
sMail.Send(mm);
}
catch (Exception ex)
{
//do something
}
}
Apr 29, 2011
C# send mail by smtp with html body
張貼者: Brian 於 09:03
標籤: Sharepoint 2010
Subscribe to:
Post Comments (Atom)
0 意見:
Post a Comment