asp.net 2.0 problems with sending e-mail

Source: Internet
Author: User
Tags lowercase mail new features mailmessage smtpclient
Asp.net| issue in the new release of ASP.net 2.0, Microsoft no longer recommends using the System.Web.Mail namespace instead of the new System.Net.Mail namespace. Many new features have been introduced into the new library, but there are some minor errors in how the message is sent.

   first, send mail

Before we discuss these small errors in detail, let's take a look at a sample code (we assume you've added a "using System.Net.Mail" to the file):

MailMessage msg = new MailMessage ();
Msg. from = new MailAddress ("address@domain.com", "person ' s Name");
Msg. To.add (New MailAddress ("destination@domain.com", "Addressee ' Name");
Msg. To.add (New MailAddress ("destination2@domain.com", "Addressee 2 ' Name");
Msg. Subject = "message Subject";
Msg. BODY = "Mail body content";
Msg. Isbodyhtml = true;
Msg. Priority = Mailpriority.high;
SmtpClient C = new SmtpClient ("mailserver.domain.com");
C.send (msg);

The above code is not much worse than the implementation in previous versions, and only minor changes were made when the message was specified. You don't have to build an address on your own, you can completely get the system to do it for you. If you specify an e-mail address and a name, it automatically displays the following in the message:

"Person ' s Name" <destination@domain.com>

This is exactly the "correct" format for an e-mail address. Of course, you can further add multiple addresses to the TO,CC and Bcc collections in exactly the same way as above. It is much easier to send a large number of messages in this way than to send each message separately-just add multiple addresses to the BCC property to achieve mass mailing.

   Ii. the existing problems

Now, let's analyze some of the small errors that exist.

As mentioned earlier, this new namespace contains some minor errors. The first is that when you send an e-mail message, the header information is all added in lowercase letters. However, in the specification of the RFC for SMTP mail, you do not specify how the headers should be capitalized, but many spam filtering programs limit e-mail messages that have no correct capitalization on the head.

Another error is related to the priority setting-through the priority setting, the user can specify how important a message is to the mail client. Because of this formatting of the headers (all lowercase), my mail program (Eudora) does not recognize the corresponding priority flag, and therefore does not specifically mark the importance of this message. Although this may seem trivial, there is no obvious reason to switch to a new version of System.Web.Mail.

Therefore, I will continue to explore this issue, if I can not find a good remedy, then I just go back to the previous System.Web.Mail to more effectively solve the warning problem.

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.