Unified by one mailbox to send the employment notice string strfrom = "";//Sender's mailbox address string strpow = "";//Mailbox Password string strserver = "";//Send mail server string strto = "";//Recipient address string strtitle = "Mail Header"; String strdody = "<div style= ' font-size:14px; ' > Email Content </div> "; string file1 = Server.MapPath ("attachment. Doc");//Attachment address 1 string file2 = Server.MapPath ("attachment. pdf");//Attachment Address 2//Send Mail Methods//send (strserver, Strfrom, Strpow, Strto, strtitle, strdody); SmtpClient client = new SmtpClient (strserver); Client. useDefaultCredentials = false; Client. useDefaultCredentials = true; Client. Credentials = new System.Net.NetworkCredential (strfrom, Strpow); Client. Deliverymethod = Smtpdeliverymethod.network; Byte[] B = Encoding.Default.GetBytes (strdody); Strdody = encoding.getencoding ("gb2312"). GetString (b). ToString (); Create an object of the message attachment class with the syntax format System.Net.Mail.AttachmenT (filename, file format) System.Net.Mail.Attachment myAttachment1 = new System.Net.Mail.Attachment (File1, Syst Em. Net.Mime.MediaTypeNames.Application.Octet); System.Net.Mail.Attachment MyAttachment2 = new System.Net.Mail.Attachment (file2, System.Net.Mime.MediaTypeName S.application.octet); MailMessage message = new MailMessage (strfrom, Strto, strtitle, strdody); Message. Attachments.Add (myAttachment1);//Use the Attachments attribute in the SmtpClient object to add the Myattachment message set above. Attachments.Add (MyAttachment2); Message. bodyencoding = Encoding.UTF8; Message. Isbodyhtml = true; Client. Send (message);
There are many default methods in sending mail, and if you have any problems, update them at any time!
C # Mail sending feature