Mail attachment fails with an exception(0)

running on MAC
when try to attach a file to an email using class EmailAttachment i get an exception on the folderitem
argument at .Append(file)

please advise

see screen shot

mail is probably nil ? how did you initialize it ?

mail.Attachments.Add not mail.Attachments.Append
take a look hier: Xojo - Send an email with attachment using smtpsecuresocket - YouTube

mail initialized as a global property, due to need it to stay around for attachments being added before
clicking the send button.

using 2019.r 1
mail.Attachments.Append is what this version supports.

Where you initialize it, make sure you don’t have a dim mail as EmailMessage line. Just mail = New EmailMessage.


Initialized as a Property, there is no Dim line for mail. ahh
i did not use a “New EmailMessage” before calling the mail.Attachment

could that be the problem. ?

ah Tim

before any call to mail.Method is called, it must have a mail = New EmailMessage
which i was missing in my code.
Since you mentioned the Dim Declare it lead me to the solution