Asp.net email garbled? · T ??? ÷ μ? ′? Why? Á ?? ? Bytes

Source: Internet
Author: User
Tags mailmessage

 

Bool result = false;
String mailaddress = configurationmanager. receivettings ["mailaddress"]. tostring ();
String mailname = configurationmanager. receivettings ["mailname"]. tostring ();
String mailpwb = configurationmanager. receivettings ["mailpwd"]. tostring ();
String mailsmtp = configurationmanager. receivettings ["mailsmtp"]. tostring ();
Mailmessage mailobj = new mailmessage ();
Mailobj. From = mailaddress;
Mailobj. To = xxxxxxx@126.com;
Mailobj. Subject = "your password ";
Mailobj. bodyformat = mailformat. html;
Mailobj. Body = "// Mailobj. bodyencoding = system. Text. encoding. default;
Mailobj. bodyencoding = system. Text. encoding. utf8;
Mailobj. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); // Basic Authentication
Mailobj. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", mailname); // set your username here
Mailobj. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", mailpwb); // set your password here
// Mailobj. bodyencoding = system. Text. encoding .;
// Mailobj. bodyencoding = system. Text. encoding. getencoding ("gb2312"); // The email encoding.

 

Smtpmail. smtpserver = mailsmtp;
Try
{
Smtpmail. Send (mailobj );
Result = true;
}
Catch (system. Exception ex)
{
Result = false;
}

Cause of error:
1. The encoding format of mail. bodyencoding is incorrect.
2. The account and password used to send the email are incorrect.
3. the SMTP address of the email sending server is set incorrectly.
In all the above three cases, email sending may fail and garbled exceptions may occur.

Related Article

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.