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.