views:

200

answers:

3

Hi all

I've just implemented some code that emails a bunch of our clients with a CSV file attachment.

Some (not many) have got back to us complaining that they don't get an attachment at all - just the CSV text inside the body of the email. Most however are fine.

I suspect that it's different mail clients that are treating the attachment differently but I don't have enough info yet to be sure.

I'm using .NET's MailMessage class with the Attachment.CreateAttachmentFromString() method. The MIME type I'm specifying for the attachment is text/csv.

Anyone have any idea what the heck is going on?

Ta muchly

David

A: 

You are probably on the right track. I would start by asking those who have the issue exactly what client and version they are using, have them forward you the message that they received. And if you find that those messages can be opened correctly from your client, offer a list of acceptable clients they can forward to as a temporary work around.

After that, it's all digging into docs, and figuring out how to make it work.

Good luck.

EDIT

It would probably also be a good idea to find out if they are opening their email plain text, or html, and if their company has any policies about attachments that may be configured into their clients.

Matthew Vines
A: 

Just as an FYI, CSV is one of the worst formats I've ever encountered. It consistantly breaks and is governed by rules that are against the geneva conventions for biological warfare.

C Bauer
I'm thinking about trying Excel 2003 XML instead, as I have a library to do that, but I wasn't sure how 'universal' it would be. What are your thoughts?
David
XML is fairly standard and comes up in a variety of places. Internet websites can even parse XML into documents. However, go with what you think is most accessible. If you can use xls, that's the most accessible to the average user (assuming you have less then 65k rows guarenteed). CSV is just error prone and a nightmare whenever I have to work with it.
C Bauer
A: 

Another possibility is that the failing email clients do not recognize the MIME type 'text/csv' and thus are showing the content uninterpretted in-line -- it may actually go through better as 'text/plain'.


Edit: I just sent a test message with a CSV attachment from Outlook to my Gmail, and used the menu option "Show original" to see the actual multi-part content, and this is what I see:

Content-Type: application/octet-stream; name="test.csv"
Content-Description: test.csv
Content-Disposition: attachment;
  filename="test.csv";
  size=44;
  creation-date="Wed, 28 Apr 2010 14:13:20 GMT";
  modification-date="Wed, 28 Apr 2010 14:13:43 GMT"
Content-Transfer-Encoding: base64

So it looks like 'application/octet-stream' will do the trick.

ewall
Interestingly, I was able to email one of the guys with a CSV file I had attached using Outlook. He said it appeared as an attachment. So maybe if I find out the MIME type that Outlook used for the attachment, that might fix the problem?
David
(Comment formatting was screwy, so I added my results to the answer above.)
ewall
Yes, my own tests confirm this. To get a CSV file attachment to work correctly in some email clients, you have to tell them it's a binary file! Work that one out...
David