Free Support Forum - aspose.com

Header differences between Aspose.Network and System.Net.Mail


#1

Hi,

I’ve sent two simple and identical messages with Aspose.Network v3.8.2.0 and System.Net.Mail (.NET 2.0) and the headers present some differences that I’d like to understand. More precisely, I’d like confirmation that they do not hinder email delivery, readability or spam scores…

Aspose.Network version

Return-Path: noreply@mydomain.com
Received: from COMPUTERNAME ([xxx.xxx.xxx.xxx])
by mail.mydomain.com
with hMailServer ; Fri, 2 May 2008 19:26:00 -0400
Message-ID: <378DE13CEB05CB478AEF9FBFA24BF2ED@computername>
Date: Fri, 2 May 2008 19:25:59 -0400
Sender: “mydomain.comnoreply@mydomain.com
From: “Someone” someone@somewhere.com
Subject: Header test mail
To: “” support@mydomain.com
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
System.Net.Mail version
Return-Path: noreply@mydomain.com
Received: from COMPUTERNAME ([xxx.xxx.xxx.xxx])
by mail.mydomain.com
with hMailServer ; Fri, 2 May 2008 19:46:19 -0400
Message-ID: <0C626374-C2C1-4F4D-B00C-29F5E800C58D@mail.mydomain.com>
MIME-Version: 1.0
From: “Someone” someone@somewhere.com
Sender: mydomain.com noreply@mydomain.com
To: support@mydomain.com
Date: 2 May 2008 19:46:19 -0400
Subject: =?iso-8859-1?Q?Header test mail?=
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Here’s how the emails were sent :
Aspose.Network
Aspose.Network.License license = new Aspose.Network.License();
license.SetLicense(AppDomain.CurrentDomain.BaseDirectory + “license/Aspose.Total.lic”);

Aspose.Network.Mail.MailMessage email = new Aspose.Network.Mail.MailMessage();
email.Sender = new Aspose.Network.Mail.MailAddress(Constants."noreply@mydomain.com", “mydomain.com”);

email.From = new Aspose.Network.Mail.MailAddress("someone@somewhere.com", “Someone”);
email.Subject = “Header test mail”;
email.SubjectEncoding = System.Text.Encoding.GetEncoding(28591); //ISO-8859-1 (Western ISO)
email.To.Add(new Aspose.Network.Mail.MailAddress("support@mydomain.com"));
email.TextBody = [some plain text];
email.BodyEncoding = System.Text.Encoding.GetEncoding(28591); //ISO-8859-1 (Western ISO)

Aspose.Network.Mail.SmtpClient client = new Aspose.Network.Mail.SmtpClient(“mail.mydomain.com”);
client.AuthenticationMethod = Aspose.Network.Mail.SmtpAuthentication.None;
client.Send(email);
System.Net.Mail
System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage();
email.Sender = new System.Net.Mail.MailAddress(Constants."noreply@mydomain.com", “mydomain.com”);

email.From = new System.Net.Mail.MailAddress("someone@somewhere.com", “Someone”);
email.Subject = “Header test mail”;
email.SubjectEncoding = System.Text.Encoding.GetEncoding(28591); //ISO-8859-1 (Western ISO)
email.To.Add(new System.Net.Mail.MailAddress("support@mydomain.com"));
email.Body = [some plain text];
email.BodyEncoding = System.Text.Encoding.GetEncoding(28591); //ISO-8859-1 (Western ISO)

System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(“mail.mydomain.com”);
client.Send(email);
A few questions :
Why is the Message-ID @ suffix different?
Why is the message subject and body encoding not set to what I asked with Aspose ?

Thanks a lot for your help,

Dominic.

#2

Hello,

1. Message-ID can be defined in Mail sending client. It is ok to use the computer name as the suffix.

2. Aspose.Network will use proper encoding automatically for subject and body encoding. The SubjectEncoding and BodyEncoding is kept there for code compliant to the System.Net.Mail.

3. The header sequence will not have any negative impacts as I know.


#3

Thanks for your reply,

Concerning 2), some users (like @yahoo.ca) complain about accentuated characters being unreadable. Like in the following passage :

…téléphoner au bureau à Valérie ou Myriam qui s’est ajoutée à notre
équipe dernièrement…
It should read
…téléphoner au bureau à Valérie ou Myriam qui s’est ajoutée à notre équipe dernièrement…
It doesn’t happen with everyone and I’m pretty sure it has something to do with the encoding, but can’t seem to solve it.

I tried forcing the encoding to “iso-8859-1”, but it seems like Aspose changes it to “utf-8” and some mail reader don’t handle that very well…

The message text comes from a web multiline textbox most probably filled by copy-paste from Word or another program. Do you have any idea what I could do to solve this situation?

Thanks
Dominic.



#4

Hello,

Please try the attached dll, I have made a hotfix for this issue.

1. Set the SubjectEncoding before set the Subject

2.Set the bodyEncoding before set the HtmlBody

Sample code:

Aspose.Network.Mail.MailMessage email = new Aspose.Network.Mail.MailMessage();
email.From = new Aspose.Network.Mail.MailAddress("user2@aspose.com", "kyle.huang");
email.To.Add(new Aspose.Network.Mail.MailAddress("to@aspose.com", "kyle.huang"));
email.SubjectEncoding = System.Text.Encoding.GetEncoding(28591); //ISO-8859-1 (Western ISO)
email.Subject = "Header test mail";
email.BodyEncoding = System.Text.Encoding.GetEncoding(28591);
email.TextBody="test";
email.HtmlBody = "test";
...

smtpclient.Send(email);


#5

Hi, I`ve tried the fix over the last few days and the encoding seems right…

A question though :
What happens now if I do not force an encoding ? Does the previous auto-detection functionnality still exists and takes over ?

Thanks for your help,

Dominic.


#6

Correct.

If you don't specify the encoding, it will try to guess one for you according to the content.

Thanks,