SMTP and application/pdf Content-Type

I am trying to send an email with a PDF attachment using SMTP calls.  I have successfully done this sending text file attachments but now I need to send a PDF file attachment.  Below is the piece of the code I am having trouble with.  I think I am missing something but not sure what.  Any help is appreciated.  Thank you.

sSend = ""
sSend = sSend & "From: Me" & Chr(13) & Chr(10)
sSend = sSend & "To: " & SendTo & Chr(13) & Chr(10)
sSend = sSend & "Subject: " & Subject & Chr(13) & Chr(10)
sSend = sSend & "MIME-Version: 1.0" & Chr(13) & Chr(10)
sSend = sSend & "Content-Type: multipart/mixed;" & Chr(13) & Chr(10)
sSend = sSend & " boundary=testboundry" & Chr(13) & Chr(10)
sSend = sSend & Chr(13) & Chr(10)
sSend = sSend & "--testboundry" & Chr(13) & Chr(10)
sSend = sSend & "Content-Type: text/html" & Chr(13) & Chr(10)
sSend = sSend & Chr(13) & Chr(10)
sSend = sSend & Message & Chr(13) & Chr(10) & Chr(13) & Chr(10)
sSend = sSend & "--testboundry" & Chr(13) & Chr(10)
sSend = sSend & "Content-Type: application/pdf; name=""Test.pdf"";" & Chr(13) & Chr(10)
sSend = sSend & "Content-Transfer-Encoding: base64;" & Chr(13) & Chr(10)
sSend = sSend & "Content-Disposition: attachment; filename=""Test.pdf"";" & Chr(13) & Chr(10) & Chr(13) & Chr(10)
sSend = sSend & "--testboundry--"
sSend = sSend & Chr(13) & Chr(10) & "." & Chr(13) & Chr(10)
beckercdAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JesterTooCommented:
Try this modified version to see if it solves the problem...

sSend = ""
sSend = sSend & "From: Me" & Chr(13) & Chr(10)
sSend = sSend & "To: " & SendTo & Chr(13) & Chr(10)
sSend = sSend & "Subject: " & Subject & Chr(13) & Chr(10)
sSend = sSend & "MIME-Version: 1.0" & Chr(13) & Chr(10)
sSend = sSend & "Content-Type: multipart/mixed;" & Chr(13) & Chr(10)
sSend = sSend & " boundary=testboundry" & Chr(13) & Chr(10)
sSend = sSend & Chr(13) & Chr(10)
sSend = sSend & "--testboundry" & Chr(13) & Chr(10)
sSend = sSend & "Content-Type: text/html" & Chr(13) & Chr(10)
sSend = sSend & Chr(13) & Chr(10)
sSend = sSend & Message & Chr(13) & Chr(10) & Chr(13) & Chr(10)
sSend = sSend & "--testboundry" & Chr(13) & Chr(10)
sSend = sSend & "Content-Type: application/octet-stream" & Chr(13) & Chr(10)
sSend = sSend & "Content-Transfer-Encoding: base64" & Chr(13) & Chr(10)
sSend = sSend & "Content-Disposition: attachment;" & Chr(13) & Chr(10)
sSend = sSend & " filename=""Test.pdf"" & Chr(13) & Chr(10) & Chr(13) & Chr(10)
sSend = sSend & "--testboundry--"
sSend = sSend & Chr(13) & Chr(10) & "." & Chr(13) & Chr(10)
beckercdAuthor Commented:
Same results, I get a 64 byte file attachment which Acrobat Reader won't open.  I think I need to some how read the file but since it isn't a text file, I am not sure how that part should work.
softplusCommented:
This is not quite so simple. You need to encode the file using something (you can't send binary data via email directly, you must "change" it into text and then "change" it back when you recieve it; that's what the encodings are for); you have "Content-Transfer-Encoding: base64", you could use that.
You can use something like this: http://www.aspsimply.com/vb/MIMECode.aspx (among lots of others ...)
You would then add:
sSend = sSend & B64EncodeFileToMail( NameOfPdfFile )
just above your last --testboundry--

Alternately, you could go with any of the 3rd party mail-objects available, most of them do all of this for you :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
beckercdAuthor Commented:
I am just going to change the file I am generating from a PDF file to an RTF so I can use my existing code that was working for text files.  I am out of time to research this anymore.  Thank you for all your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.