intermittent problem sending PDF as email attachment

HI,

I have an issue sending PDF’s where they arrive as mime-attachments in the clients email app. this is happening on mail(iOS) mail.app(OSX) 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?

Regards,

Russ

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
mail.fromAddress=fromaddress
mail.subject=subject

if bodyashtml then
mail.bodyHTML = body
else
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))
next

//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))
next

//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

end

//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 mail.app,
the attachment shows as application/base64.

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

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

a Delivery from
emin

–qev34o7oxvi4
Content-Type: application/base64; name=“Delivery76400.pdf”;
x-mac-type=“3F3F3F3F”
x-mac-creator=“3F3F3F3F”
Content-transfer-encoding: Base64
Content-disposition: attachment

JVBERi0xLjMNCjEgMCBvYmogPDwgL1R5cGUgL0NhdGFsb2cgL1BhZ2VzIDIgMCBSID4+IGVuZG9i
ag0KDQoyIDAgb2JqIDw8IC9UeXBlIC9QYWdlcyAvS2lkcyBbIDQgMCBSIF0gL0NvdW50IDEgPj4g
ZW5kb2JqDQoNCjMgMCBvYmogPDwgDQovUHJvZHVjZXIgKGhjc3JwdCAyMDE1LjEuMCkNCi9BdXRo
b3IgKGRlYW4pDQovQ3JlYXRpb25EYXRlIChEOjIwMTUwMzA1MDg1NTE5MDAnMDAnKQ0KL0NyZWF0
b3IgKGhjc3JwdCAyMDE1LjEuMCkNCi9LZXl3b3JkcyAoKQ0KL1N1YmplY3QgKCkNCi9UaXRsZSAo
KQ0KL01vZERhdGUgKEQ6MjAxNTAzMDUwODU1MTkwMCcwMCcpDQogPj4gZW5kb2JqDQoNCjQgMCBv
YmogPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAgMiAwIFIvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAv
UmVzb3VyY2VzIDYgMCBSIC9Db250ZW50cyA1IDAgUiAgPj4gZW5kb2JqDQoNCjUgMCBvYmogPDwg
L0xlbmd0aCAxMDA2OCAgPj4gc3RyZWFtDQpCVA0KL0YxIDEyIFRmDQoxIDAgMCAxIDQzOS4zNzAx
IDgwMS42NTM2IFRtDQowIDAgMCByZw0KKEZhcm1lcnMgRnJlc2ggTGltaXRlZClUag0KRVQNCkJU
DQovRjEgMTIgVGYNCjEgMCAwIDEgNDk2LjA2MyA3ODcuNDgwNCBUbQ0KKFRoZSBBYmF0dG9pcilU
ag0KRVQNCkJUDQovRjEgMTIgVGYNCjEgMCAwIDEgNDkwLjM5MzcgNzczLjMwNzEgVG0NCihSb3Vu
Y2lsIExhbmUpVGoNCkVUDQpCVA0KL0YxIDEyIFRmDQoxIDAgMCAxIDUwNC41NjY5IDc1OS4xMzM5
IFRtDQooS2VuaWx3b3J0aClUag0KRVQNCkJUDQovRjEgMTIgVGYNCjEgMCAwIDEgNDg3LjU1OTEg[/code]

@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

STARTTLS
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??

nevermind!

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.