Public Void Sendmail ()
{
// Instantiate a mailmessage object
System. Web. Mail. mailmessage mail = New System. Web. Mail. mailmessage ();
// Define the mail sending Address
Mail. From = " Aierong@126.com " ;
// Define the email Receiving address
// Set a list of recipient email addresses separated by semicolons
Mail. = " Aierong@126.com " ;
// Defines the mail's dark sending Address
// Set the list of email addresses separated by semicolons
Mail. bcc = " A@126.com " ;
// Define the CC address of an email
// Set the list of email addresses separated by semicolons
Mail. CC = " Abc@371.net aaa@263.net " ;
// Define the subject of an email
Mail. Subject = " . Net email " ;
// Set the email body content type
// Here, we send messages in HTML Format
Mail. bodyformat = System. Web. Mail. mailformat. html;
// Set email body
Mail. Body = " Go go " ;
// Set an attachment
System. Web. Mail. mailattachment = New System. Web. Mail. mailattachment ( @" D: \ abc.doc " );
// Attach an attachment to the email
Mail. attachments. Add (mailattachment );
// SMTP Server
// Authentication is required for many SMTP servers.
System. Web. Mail. smtpmail. smtpserver = " Smtp.126.com " ;
// Verify
Mail. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/smtpauthenticate " , " 1 " );
// Login Name
Mail. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/sendusername " , " Aierong " );
// Login Password
Mail. Fields. Add ( " Http://schemas.microsoft.com/cdo/configuration/sendpassword " , " ******* " );
// Send
System. Web. Mail. smtpmail. Send (Mail );
}
This method can send an email to the Internet
ReferenceArticleYou can see
Http://www.systemwebmail.com/faq/3.8.aspx