The problem of sending emails is only for favorites)

Source: Internet
Author: User
Tags mailmessage smtpclient

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.