system.net.sendEmail with optional attachment

Hello,
Using the system.net.sendemail function, I would like to make sending attachments in an email optional.

In this case, how do I write the [attachmentNames] and [attachmentData] arguments in the function?

Thank you for your help.

Manu

1 Like

Thanks for your reply, and without attachments with the same code is it ok?

Yeah just omit the two attachment parameters.

If you have no attachments you can use simpler code;

# This code would send a simple plain-text email to a single recipient, with no attachments
body = "Hello, this is an email."
recipients = ["bobsmith@mycompany.com"]
system.net.sendEmail("mail.mycompany.com",
 "myemail@mycompany.com", "Here is the email!", body, 0, recipients)
1 Like

That code only executes if there is a valid filepath, so there has to be an attachment.

1 Like