Ignition Edge sends emails but no attachments

This works for me, albeit I didn’t test on Edge;

filePath = system.file.openFile()
if filePath != None:
   # This gets the filename without the C:\folder stuff
   fileName = filePath.split("\\")[-1]
   fileData = system.file.readFileAsBytes(filePath)
   smtp_server = "test"
   sender = "test"
   subject_mail = "Here is the file you requested"
   body_mail = "Hello, this is an email."
   recipients = ["test"]
   
   system.net.sendEmail(
   	smtpProfile = smtp_server, fromAddr = sender, 
   	subject = subject_mail, body = body_mail, html = 0, 
   	to = recipients, attachmentNames = [fileName], 
   	attachmentData = [fileData])

image

1 Like