intermittent problem sending PDF as email attachment


I have an issue sending PDF’s where they arrive as mime-attachments in the clients email app. this is happening on mail(iOS) and a third party software on windows.

I have the mime type set to “application/pdf” on the attachment, which i thought was correct. (and it does work fine on most systems)
it has worked fine for years, but in the last two weeks, i’ve got three users complaining about it and i’m worried its going to become an avalanche!

does anybody have any ideas what i can test to see what might be going wrong?



Can you show some code?

Does it work better using CURLEMailMBS Class?

well the code i use is below

I’ve not tried your class. if i cant get this working i will give it a go, but i’m hoping its just a missing header or something easy!

[code] Dim mail as EmailMessage
Dim file as EmailAttachment
Dim i as Integer
Dim s as String

mail = New EmailMessage

if bodyashtml then
mail.bodyHTML = body
mail.bodyPlainText =body
end if

mail.Headers.AppendHeader “Content-Type”, “text/plain; charset=UTF-8;”
mail.headers.appendHeader “X-Mailer”,“Email Message”
mail.headers.appendHeader “X-Comment”,str(msgid)

if Receipt then
mail.headers.AppendHeader “Disposition-Notification-To”,fromaddress //read receipt
end if
if replyto <> “” then
mail.headers.AppendHeader “Reply-To”, ReplyTo // different reply to address.
end if

s = toaddress
//multiple To addresses separated by commas or semi colons
s = s.ReplaceAll(";",Chr(13))
s = s.ReplaceAll(",",Chr(13))

For i = 1 to CountFields(s,Chr(13))
mail.addRecipient Trim(NthField(s,Chr(13),i))

//multiple CC addresses separated by commas or semi colons
s = ccto
s = s.ReplaceAll(";",Chr(13))
s = s.ReplaceAll(",",Chr(13))

For i = 1 to CountFields(s,Chr(13))
mail.addCCRecipient Trim(NthField(s,Chr(13),i))

//add attachments, if any
If Attach <> “” then //is there a path to an attachment file?
file = New EmailAttachment
file.MIMEType = “application/pdf”
file.loadFromFile GetFolderItem(Attach.trim)
mail.attachments.append file //add file to attachments array


//send the mail
SMTP.messages.append mail //add email to list of messages
SMTP.SendMail //send message[/code]

I would guess that GetFolderItem(Attach.trim) is wrong.

This function without second parameter should only take file name.

im not sure i understand
its not that the correct file isnt attached, it is. if the email client saves it, then it saves ok and opens as a pdf
on IOS they can open it with pdf reader and its fine, its as if the email client doesnt know its a pdf.

funnily enough, when i view the raw source in,
the attachment shows as application/base64.

[code]X-Mailer: Email Message
X-Comment: 6752
Content-Type: multipart/mixed; boundary=“qev34o7oxvi4”
Mime-Version: 1.0

Content-type: text/plain; charset=UTF-8;
Content-transfer-encoding: 7bit

a Delivery from

Content-Type: application/base64; name=“Delivery76400.pdf”;
Content-transfer-encoding: Base64
Content-disposition: attachment


@Christian Schmitz

i’m looking at your sendemail example in the plugins.
its converting a jpeg to a string using pictureToJpegStringMBS

how do i do that with a pdf file?

please set file.MIMEType after you load attachment.

Please add CURL, Main and JPEG Plugins from MBS collection.

sorry, i dont want to load a JPEG, i want to load a PDF,

do i just use a textinputstream and do a readall?

don’t use textinputstream for PDF files.
Use Binarystream and read there the whole file.

ok, im using Gmail, and i got an error of 55 (530 5.7.0 Must issue a STARTTLS command first. e2sm10456774wjy.46 - gsmtp)

so I uncommented the line in your test app

// add this to use TLS
’ d.OptionFTPSSL = 3

but now i get error 60

220 2.0.0 Ready to start TLS
SSLv3, TLS handshake, Client hello (1):
SSLv3, TLS handshake, Server hello (2):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS alert, Server hello (2):
SSL certificate problem: unable to get local issuer certificate
Closing connection 0

what am i doing wrong??


i needed
email.UseSSL = true

its working great now, and as a bonus, the PDF seems to be inline too!
i will rework my program to use your plugin instead of the Xojo stuff

Thanks Christian

Thank you.