Direct appendix to the main code bar
static void Main (string[] args)
{
SmtpClient client = new SmtpClient ("smtp.126.com");
MailAddress from = new MailAddress ("*****@126.com", "* * *", ENCODING.UTF8);//Outgoing Mail
MailAddress to = new MailAddress ("* * * * * * @qq. com", "* * * *", ENCODING.UTF8);//mail address
MailMessage message = new MailMessage (from, to);
Attachment atta = new Attachment (@ "C:\Users\HBD\Desktop\ Tsai English 520 inaugural speech");//file path
Message. Attachments.Add (Atta);
Message. Subject = "Test subject";
Message. subjectencoding = Encoding.UTF8;
Message. Body = "Mail Content";
Message. bodyencoding = Encoding.UTF8;
Client. Deliverymethod = Smtpdeliverymethod.network;
Client. useDefaultCredentials = false;
NetworkCredential MYNP = new NetworkCredential ("*******@126.com", "* * * * *");//Account and password
Client. Credentials = MYNP;
Client. Send (message);
}
C # Send mail