Reference namespaces:
Using System.Net.Mail;
<summary>
Send HTML mail with cc and BCC
Need to be configured in the Mailsettings node under System.Net in the Web. config file
</summary>
<param name= "mailto" > Recipient address </param>
<param name= "MAILCC" > CC address </param>
<param name= "MAILBCC" > Secret delivery address </param>
<param name= "Mailsubject" > Email subject </param>
<param name= "Mailbody" > Message body </param>
public static void SendMail (String mailto, string mailcc, String mailbcc, String mailsubject, String mailbody)
{
MailMessage mmessage = new MailMessage ();
MailAddress mTo = new MailAddress (mailto);
if (MAILCC! = "") {mailaddress MCC = new MailAddress (MAILCC); MMESSAGE.CC.ADD (MCC); }
if (mailbcc! = "") {mailaddress mbcc = new MailAddress (MAILBCC); MMESSAGE.BCC.ADD (MBCC); }
MMESSAGE.TO.ADD (MTo);
Mmessage.subject = Mailsubject;
The character encoding for both the body and the subject is set to UTF8
mmessage.subjectencoding = System.Text.Encoding.UTF8;
mmessage.bodyencoding = System.Text.Encoding.UTF8;
Mmessage.body = Mailbody;
Text supports HTML
Mmessage.isbodyhtml = true;
SmtpClient client = new SmtpClient ();
Client. Send (Mmessage);
}
Call:
SendMail ("[Email protected]", "", "", "TestData", "
Send mail using System.Net.Mail