I am currently trying to create a script that opens an image that the user selects. It will then take this image and attach it to an email that is sent out. I’ve got it so that the image loads and the email is sent out. However, whenever it does this it locks up the GUI. I’ve even added in invokeAsynchronous to the script but it will still lock up the GUI and I am confused as to why. The CPU usage never goes above 30% when this script is running (generally around 10%) and I can use other programs while it is running with no problem. Below is my code and I have it set to run when a button is clicked. Any help would be greatly appreciated.
if system.tag.getTagValue("[System]Client/User/Username") in ["user1", "user2"]:
path = system.file.openFile()
if path != None:
def longProcess(path = path):
bytes = system.file.readFileAsBytes(path)
def afterLongProcess(bytes = bytes):
smtp = "smtp.gmail.com:587:tls"
fromAddr = "firstname.lastname@example.org"
subject = "Subject"
body = "Body"
recipients = ["email@example.com"]
fileData = bytes
fileName = "Image_1.png"
password = "password"
system.net.sendEmail(smtp, fromAddr, subject, body, 0, recipients, [fileName], [fileData], 60000, fromAddr, password)
system.gui.messageBox("Email was successfully sent.", "Email Complete")
system.gui.warningBox("No Image Selected", "Warning")