All of the documentation is old or includes commands that are no longer supported. Any help?
I want to send a pdf . . .
All of the documentation is old or includes commands that are no longer supported. Any help?
I want to send a pdf . . .
What is out of date? Which “commands” aren’t working? What have you tried?
var s as new smtpSecureSocket
s.address = “mail.circleconsulting.us”
s.port = 465
's.sslConnectionType = smtpSecureSocket.sslConnectionTypes.TLSv1
's.sslEnabled = true
s.username = “manager@circleconsulitng.us”
s.password = “My Password”
var mail as new emailMessage
mail.fromAddress = “manager@circleconsulting.us”
mail.addRecipient(“jvscanlan@q.com”)
mail.subject = “xojo test”
mail.bodyPlainText = “test”
mail.headers.addHeader(“x-mailer”, “smtp test”)
s.messages.add(mail)
s.sendMail
system.debugLog(“Send mail: done”)
Code like that never worked because the smtpSecureSocket goes out of scope before sending.
Actually I got it to work after posting:
var s as new smtpSecureSocket
s.address = “mail.circleconsulting.us”
s.port = 465
s.sslConnectionType = smtpSecureSocket.sslConnectionTypes.SSLv23
s.sslEnabled = true
s.username = “manager@circleconsulting.us”
s.password = “My Password”
s.connect
var mail as new emailMessage
var f as folderItem = getFolderItem(“”).parent.child(“ASU 2023-02-18.pdf”)
mail.fromAddress = “manager@circleconsulting.us”
mail.addRecipient(“jvscanlan@q.com”)
mail.subject = “xojo test”
mail.bodyPlainText = “test”
mail.headers.addHeader(“x-mailer”, “smtp test”)
if f <> nil and f.exists then
var a as new emailAttachment
a.loadFromFile(f)
a.name = f.name
a.mimeType = “application/pdf”
mail.Attachments.add(a)
end if
s.messages.add(mail)
s.sendMail
Make s a property of the webpage. That way you are sure it won’t go out of scope.
Thanks. The above programming shows a static file. My web app creates a webfile (pdf) and then shows it in a HTML viewer. Now I need to find a way to capture the webfile so I can email it.
Any ideas?
Simply save the PDF to disk and use your present code to fetch it.
Can’t find a command to save the webfile. All I see is naming the file.
myWebFile = New webfile
myWebFile.mimetype = “application/pdf”
myWebFile.filename = “CircleCalcParis.pdf”
myWebFile.data = pdfData
You have the PDF data, you can attach that to an EmailMessage through the EmailAttachment class:
https://documentation.xojo.com/api/networking/emailattachment.html#emailattachment-parseattachment
I’m trying attachment.parseAttachment: All of these create this message when opening the received email: “There was an error while reading a stream.”
a.parseAttachment(“application/pdf”, “UTF8”,pdfdata)
a.parseAttachment(“application/pdf”, “base64”,pdfdata)
a.parseAttachment(“application/pdf”, “BASE_64_ENCODED_PDF”,pdfdata)
a.parseAttachment(“application/pdf”, “”,pdfdata)
What should it be?
I am honestly not sure what the header string is supposed to look like. You’ll have to ask them to document it with an issues ticket.
It seems like no matter what I set, the Name property is never being set, so let’s just do it the old fashioned way:
var oAttach as new EmailAttachment
oAttach.ContentEncoding = "Base64"
oAttach.Data = EncodeBase64(pdfData)
oAttach.MIMEType = "application/base64"
oAttach.Name = "My PDF.pdf"
That did it. Needed the encodeBase64 part instead of parse.