tags:

views:

2460

answers:

7

Hi,

I have written some code in my VB.NET application to send an HTML e-mail (in this case, a lost password reminder).

When I test the e-mail, it gets eaten by my spam filter. One of the things that it's scoring badly on is because of the following problem:

MIME_QP_LONG_LINE  RAW: Quoted-printable line longer than 76 chars

I've been through the source of the e-mail, and I've broken each line longer than 76 characters into two lines with a CR+LF in between, but that hasn't fixed the problem.

Can anyone point me in the right direction?

Thanks!

A: 

How do you try to send the email? If you create a MailMessage object (via System.Net.Mail), it even has the property IsBodyHtml and it takes care of all of the formatting and everything.

Biri
A: 

@Biri

Yes - I'm using the MailMessage object, and I've set IsBodyHtml to true.

When I whitelist the sending address from the spam filter, the message works (and displays) correctly. It's just that the spam filter is marking me down because of this 'error'.

Any other ideas? I'm keen to do all I can to improve my e-mail's spam score so that it has more chance of working for my application's users.

Chris Roberts
+2  A: 

Quoted printable expands 8 bit characters to "={HEX-Code}", thus making the messages longer. Maybe you are just hitting this limit?

Have you tried to break the message at, say, 70 characters? That should provide space for a couple of characters per line.

Or you just encode the email with Base64 - all mail client can handle that.

Or you just set Content-Transfer-Encoding to 8bit and send the data unencoded. I know of no mail server unable to handle 8bit bytes these days.

pilif
+1  A: 

Why do you split the text "manually"?
Not an expert, but I would look into http://msdn.microsoft.com/en-us/library/system.net.mime.transferencoding.aspx and http://msdn.microsoft.com/en-us/library/system.net.mail.attachmentbase.transferencoding(VS.80).aspx and use AlternateView.

VolkerK
A: 

Quoted-printable is an encoding, not just a line length. You have to run the entire message through an encoding filter to modify line lengths and convert some characters to escape codes.

Eric Z Beard
A: 

Thanks for your suggestions. For clarity, what I did in the end was set the MailMessage.BodyEncoding property to System.Text.Encoding.UTF8.

Chris Roberts
A: 

This is a bug in the implementation of the Quoted-Printable encoding in System.Net.Mail.MailMessage, which has been there for a long time, but is apparently now fixed, as of .Net 4 Beta 2.

http://connect.microsoft.com/VisualStudio/feedback/details/156052/mailmessage-body-encoding-quoted-printable-violates-rfcs-soft-line-breaks-requirements

One work-around is to use Base64 encoding instead (even though it would not otherwise be good practice to send a plain-text MIME part in a non-human readable encoding like this). Asking the user of the class to manually split the lines of the message before sending it is not a general solution, as the modified message is not what they wanted to send (e.g. it might include a link which is longer than 76 chars, and so cannot be split). Quoted-Printable can handle messages with lines which are longer than 76 chars before encoding, as long as it is implemented correctly.

kymg