Step 1: view the mail server of Sina.
Ing System;
Using System. Data;
Using System. Configuration;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;
Using System. Net. Mail;
/// <Summary>
/// Summary of SendMail
/// </Summary>
Public class SendMail
{
Public SendMail ()
{
//
// TODO: add the constructor logic here
//
}
/// <Summary>
/// Send an email
/// </Summary>
/// <Param name = "MessageFrom"> sender's email address </param>
/// <Param name = "MessageTo"> recipient's email address </param>
/// <Param name = "MessageSubject"> subject </param>
/// <Param name = "MessageBody"> email content </param>
/// <Returns> </returns>
Public static string Send (MailAddress MessageFrom, string MessageTo, string MessageSubject, string MessageBody)
{
MailMessage message = new MailMessage ();
Message. From = MessageFrom;
Message. To. Add (MessageTo); // you can specify multiple recipient email addresses for group sending.
Message. Subject = MessageSubject;
Message. Body = MessageBody;
Message. IsBodyHtml = true; // whether it is in html Format
Message. Priority = MailPriority. High; // mail Priority
SmtpClient SC = new SmtpClient ();
SC. Host = ""; // specify the server address or IP address (for example, smtp.sina.com) for sending emails)
SC. Port = 25; // specify the sending Port
SC. Credentials = new System. Net. NetworkCredential ("", ""); // specify the username and password for logging on to the server (for example, "willsonu88", "yxd5387832 ")
Try
{
SC. Send (message); // Send an email
}
Catch (SmtpException ex)
{
Return ex. Message;
}
Return "email sent successfully ";
}
Step 2: If the message cannot be sent at this time, check the TCP/IP protocol of your network.
Change the DNS server configuration to 210.22.70.3.
Another backup DNS server configuration is: 202.96.209.6
At this time, the message can be sent successfully. Try again.