We help IT Professionals succeed at work.

Problem attaching PDF file using SMTP

pgiusto asked
Medium Priority
Last Modified: 2006-11-17
I have an e-mail client written in C++. I wrote it some years ago, using plain SMTP messages through sockets.
Now I have to attach some PDF files to the message, so I learned all about the MIME thing. It works fine with text files, but I have problems with PDF files.

This are the headers I put on my message:

Mime-Version: 1.0
Content-Type: application/octet-stream; name=xx.pdf
Content-Disposition: attachment; filename=xx.pdf

Next I read the xx.pdf file using fread and send it through the socket.
The message goes to the server and is received by the recipient ok.

When the recipient opens the file (with Acrobat Reader) the file is corrupt. Before each byte with value 0A, "someone" inserted an extra byte with value 0D.

I think the problem is on the message headers, but I can't figure it out.
Watch Question

We get similar problems when people send mails with attachments (using clients such as Outlook, Outlook Express) as html.

When they set their client to "Send as plain text" - attachments are received just fine. Not sure if your client has an html or plain text option - if the latter, select this before sending attachments.

Hope this helps
There has been no activity in this question in quite some time, and it looks like it has been abandoned. As part of our ongoing mission to clean up the topic areas, a Moderator will finalize this question within the next seven (7) days. At that time, either I or one of the other Moderators will force/accept the comment of omb.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER. If you have further comments on this question or the recommendation, please leave them here.

Community Support Moderator
Experts Exchange
Force/accepted by

Community Support Moderator
Experts Exchange

Explore More ContentExplore courses, solutions, and other research materials related to this topic.