c# - Mail header "From" sometimes not encoded with System.Net.Mail and .NET Framework 2.0 -


Greetings.

I have seen some other question entries here, like, but not as soon as I am getting the same problem. Perhaps a guru has experienced such a thing in the past.

Actually, I'm building an ASP.NET 2.0 web application, which sometimes needs to be sent to an e-mail (using System.Net.Mail), and I'm curious And I am facing incompatible behavior.

  1. Sends it for all e-mail messages, it's a single e-mail address, display name and encoding ("code" encoding UTF8 ) For which an MailAddress object has been created). The display name is always a word, in which there is a non-ASCII character.
  2. Each type of message has its own way MailAddress and MailAddressCollection before they come from a common method, such as, from, to topic, body ( Who actually post a message using a mailsize object and a smtpClient object). / Li>
  3. Most message types are generated correctly, base 64 and UTF-8 encoded headers (including "to").
  4. For a specific type of message, however, except for all the fields are "properly encoded" in these messages, the display name of the field is not encoded to them. , So that non-ASCII characters can be displayed as strange symbols and mail gateways are bad about encoding encoding.

The field here is an example of properly encoded:

from: =? Utf-8? B? QnJ1a2Vyc8O4a25hZA ==? = & Lt; Munged@munged.tld>

An example of a field from here is not encoded to:

From: "Brookscock" & lt; Munged@munged.tld>

"non-ASCII character" and "Absash;" is believed.

Here is the line of code for which MailAddress is creating an object (for message) type that fails to encode this field:

 < Code> mailsender = new mailadds (settings .ffdbb.email senderadder, settings.settingform.db.mail_sender_name, encoding.UTF8); Similarly, there is a line of code (for the same type of message)  MailAddress  object to to (only the difference is that it is a  MailAddressCollection ): 

  mailTo = new MailAddressCollection (); MailTo.Add (new maildude (objSøknad.Creator.Email, objSøknad.Creator.FullName, encoding.UTF8));  

And last but not least, here is the line to create MailAddress objects for a message type, in which all the fields are always correctly encoded ( It's above identical !):

  MailSendor = New maildude (settings. SettingsFormDb.Email SenderAdder, Settings.SettingFormDB.Email_ServerName, Encoding.Utf 8);  


The topic is always encoded in the same manner ( encoding. UTF8 ) and the method to mailmage object and body Encoding is always the same (normal message that is called for all messages) and, headers that are properly encoded, they are always encoded in the base 64 all messages (not quoted-printable).

Create a folder and send that code to the folder in that folder. After this, it can double click on it to display messages on Outlook, old versions of Outlook can not display items correctly, although Outlook 2010 may be. This is a mixed bag, as far as the field unicode is enabled in each outlook version - the obstacles in that area have progressed. You can also use Windows Live Mail to view this message if you can correct this problem again. In addition, you can use the CDOSIS code on the net to pose the MIM and display the results.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -