// Create a mailmessage object
Mailmessage mailmsg = new mailmessage ();
// Set the recipient's email address
Mailmsg. To = txw.text;
// Set the sender's email address
Mailmsg. From = txtfrom. text;
// Set the Email Subject
Mailmsg. Subject = txtsubject. text;
// Set the email content
Mailmsg. Body = txtmsg. text;
// Supports Server verification.
Mailmsg. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1 ");
// Set the user name
Mailmsg. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", "songxiuduo_999@163.com ");
// Set the User Password
Mailmsg. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", "sxd999 ");
// Try
//{
// Set the email sending server
Smtpmail. smtpserver = "smtp.163.com ";
// Send an email
Smtpmail. Send (mailmsg );
Lblmsg. Text = "sent successfully ";
//}
// Catch
//{
// Lblmsg. Text = "failed to send ";
//}
Note the following when running this example:
1. If your machine is equipped with anti-virus software such as rising, disable the "mail sending monitoring and mail acceptance monitoring" function.
2. Set the email server correctly.