7

I have an system that is an in house solution attempting to email invoices to clients. This system works great except for one client gets .dat files instead of the nicely generated .pdf files that everyone else gets.

I have researched the problem and many things point to issues with Outlook sending emails(not using outlook) and splitting the files because it is to large(it isn't, we can manualy send the email fine.)

The files get renamed to something like "=_utf-8_B_Q29uc29saWRhdGVkIEludm9pY2VzIGZv.dat" instead of "1180426.pdf".

After the headers on both files is just lines of characters that don't mean anything to me.

the headers of the .dat files: file1

 =?utf-8?B?Y2lCQmJIQm9ZU0JKYm5OMWJHRjBhVzl1Pz0NCiA9P3V0Zi04P0I/SUNZ?=\
\

 =?utf-8?B?Z1YyRjBaWEp3Y205dlptbHVaeUF0SUVGc2NHaGhJRWx1YzNWc1lYUnBi?=\
\

 =?utf-8?B?MjRnSmlCWFlYUmw/PQ0KID0/dXRmLTg/Qj9jbkJ5YjI5bWFXNW5JT0tB?=\
\

 =?utf-8?B?a3lCVmJtbDJaWEp6WVd3Z1EybDBlU3dnS0RJd01USXRNRFF0TVRNcD89?=\
\
 =?utf-8?B?DQogPT91dGYtOD9CP0xuQmtaZz09Pz0=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment

file2

 =?utf-8?B?YUdFZ1NXNXpkV3hoZEdsdmJpQW1JRmRoPz0NCiA9P3V0Zi04P0I/ZEdW?=\
\

 =?utf-8?B?eWNISnZiMlpwYm1jZ0xTQkJiSEJvWVNCSmJuTjFiR0YwYVc5dUlDWWdW?=\
\

 =?utf-8?B?MkYwWlhKd2NtOXY/PQ0KID0/dXRmLTg/Qj9abWx1WnlEaWdKTWdWVzVw?=\
\

 =?utf-8?B?ZG1WeWMyRnNJRU5wZEhrc0lDZ3lNREV5TFRBMExURXpLUzV3WkdZPT89?=\
\
 =?utf-8?B??="
Content-Transfer-Encoding: base64
Content-Disposition: attachment

Does anyone have any idea on why this is happening?

11
  • have you try to change "invoice" to "rebate"? maybe it'll solve the problem :)
    – Ray Cheng
    Commented Apr 21, 2012 at 6:17
  • looks like your pdf is being base64 encoded. since you can send the invoice fine manually, i suspect your mail server is to blame. have you try to use the system to send the same pdf to two clients? if one still fails, i'll suspect it's the client's mail server (receiving end)issue.
    – Ray Cheng
    Commented Apr 21, 2012 at 6:21
  • first, when you say "it isn't, we can manualy send the email fine", have you manually sent the file to SAME client with no problems? If yes, then read no further. I'll try to find some other solution. If not, it might be problem at client end(his mail server won't accept large attachments)? can you ask the client to check with his email service provider? Commented Apr 25, 2012 at 4:59
  • Yes, we can send the exact same email to the client and it works perfectly. The attachments are less than 200Kb so it isn't the large attachments. Commented Apr 25, 2012 at 13:14
  • 1
    There's a weird Unicode character being printed instead of a hyphen here in the filename: "... Waterproofing – Universal City, ...". It could be that somebody's mailserver is sensitive to non-ASCII characters and is encoding it to base64 as a result. What happens if you change your email system to use a different filename? Can you find that part in the system and re-type the hyphen?
    – Jeff
    Commented Apr 25, 2012 at 19:25

3 Answers 3

6
+50

From the comments:

There's a weird Unicode character being printed instead of a hyphen here in the filename: "... Waterproofing – Universal City, ...". It could be that somebody's mailserver is sensitive to non-ASCII characters and is encoding it to base64 as a result. Change it to a regular ASCII hyphen and it should be fine.


How I found it:

Firstly, here's the online base64 decoder I used: http://www.opinionatedgeek.com/dotnet/tools/base64decode/

Secondly, I started by concatenating all of the base64 strings from the header. It's split up into multiple segments: for the first header, there are 5 segments. The segments are the long parts between the question marks. Putting them all together, you get:

Y2lCQmJIQm9ZU0JKYm5OMWJHRjBhVzl1Pz0NCiA9P3V0Zi04P0I/SUNZ
Z1YyRjBaWEp3Y205dlptbHVaeUF0SUVGc2NHaGhJRWx1YzNWc1lYUnBi
MjRnSmlCWFlYUmw/PQ0KID0/dXRmLTg/Qj9jbkJ5YjI5bWFXNW5JT0tB
a3lCVmJtbDJaWEp6WVd3Z1EybDBlU3dnS0RJd01USXRNRFF0TVRNcD89
DQogPT91dGYtOD9CP0xuQmtaZz09Pz0=

Putting this into the decoder gives:

ciBBbHBoYSBJbnN1bGF0aW9u?=
=?utf-8?B?ICYgV2F0ZXJwcm9vZmluZyAtIEFscGhhIEluc3VsYXRpb24gJiBXYXRl?=
=?utf-8?B?cnByb29maW5nIOKAkyBVbml2ZXJzYWwgQ2l0eSwgKDIwMTItMDQtMTMp?=
=?utf-8?B?LnBkZg==?=

Another set of base64 segments. The first segment looks like it's cut off, so I assume that what went into the filename is actually part of it. So I prepend it with that and get:

Q29uc29saWRhdGVkIEludm9pY2VzIGZvciBBbHBoYSBJbnN1bGF0aW9u
ICYgV2F0ZXJwcm9vZmluZyAtIEFscGhhIEluc3VsYXRpb24gJiBXYXRl
cnByb29maW5nIOKAkyBVbml2ZXJzYWwgQ2l0eSwgKDIwMTItMDQtMTMp
LnBkZg==

Putting this into the decoder will make it spit out a .bin file because of the non-ASCII character. The bin file contains the full filename of the PDF.

Opening the bin file in a hex editor:

43 6F 6E 73 6F 6C 69 64 61 74 65 64 20 49 6E 76   Consolidated Inv
6F 69 63 65 73 20 66 6F 72 20 41 6C 70 68 61 20   oices for **** 
49 6E 73 75 6C 61 74 69 6F 6E 20 26 20 57 61 74   ********** & ***
65 72 70 72 6F 6F 66 69 6E 67 20 2D 20 41 6C 70   ********** - ***
68 61 20 49 6E 73 75 6C 61 74 69 6F 6E 20 26 20   ** ********** & 
57 61 74 65 72 70 72 6F 6F 66 69 6E 67 20 E2 80   ************* â€
93 20 55 6E 69 76 65 72 73 61 6C 20 43 69 74 79   “ ********* ****
2C 20 28 32 30 31 32 2D 30 34 2D 31 33 29 2E 70   , (2012-04-13).p
64 66                                             df

The em-dash sticks out like a sore thumb.

3
  • Thanks for your help. What did you use to find that exactly? Commented Apr 26, 2012 at 19:04
  • There's a lot of text involved, so I'll update my answer with the process.
    – Jeff
    Commented Apr 26, 2012 at 19:05
  • I removed my clients name from the answer. Change letters to *'s. Commented Apr 26, 2012 at 19:18
2

I think @Jeff E has got it right: there's a non-ASCII character in the filename, and that's causing problems on one end or the other. When you're emailing the file manually, my guess is that the em-dash is replaced with a regular hyphen or some other character (e.g. _) by your mail client. If you change the dash in "Waterproofing – Universal City" to a "-" I think this should work.

(If it does, rep should go to Jeff, as he spotted the unicode.)

0

Are you setting a MIME type when your system attaches the PDFs to the email messages? If so, what are you using? It's a shot in the dark, but it's possible that your system is not correctly using application/pdf and some combination of the mail servers and clients involved is getting confused and responding by changing it to a .dat.

Not the answer you're looking for? Browse other questions tagged or ask your own question.