Recently in doing a mailbox verification function, find a lot of code, or not satisfactory, but, after a search or have harvested, so there is the following code
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Net.Mail;
Using System.Web.Mail;
Using System.Net;
Using System.ComponentModel;
Namespace MailSender {class Program {static void Main (string[] args) {try
{MailMessage mm = new MailMessage ();
MailAddress Fromma = new MailAddress ("zjyOxcj@gmail.com");
MailAddress Toma = new MailAddress ("674026565@qq.com", null); Mm.
from = Fromma; Recipient mm.
To.add ("674026565@qq.com"); Mailbox title mm.
Subject = "Hello Dear:"; Mm.
Isbodyhtml = true; Message content mm. BODY = "Hello, Mr Meteor."
"; The encoding format for the content mm.
bodyencoding = System.Text.Encoding.UTF8; Mm.
ReplyTo = Toma; Mm.
Sender =fromma; Mm.
Isbodyhtml = false;Mm.
Deliverynotificationoptions = deliverynotificationoptions.onsuccess; Mm. Cc.
ADD (Toma);
SmtpClient sc = new SmtpClient ();
NetworkCredential NC = new NetworkCredential (); nc. UserName = "zjyOxcj@gmail.com";//Your email address NC. Password = "Password";//Your email password, here the password is xxxxx@qq.com mailbox password, special instructions under ~ SC.
useDefaultCredentials = true; Sc.
Deliverymethod = Smtpdeliverymethod.network; Sc.
Credentials = NC; Sc.
Enablessl = true; Sc.
Port = 587; If you report mail from address must is same as authorization user this error, is your QQ mailbox does not open SMTP, SC.
Host = "smtp.gmail.com"; Sc.
Send (mm); The catch (Exception ex) {Console.Write (ex). Message + "" + Ex.
Source); }
}
}
}