Indentation? Does your original code have any? It needs it as Jython is very sensitive about it. Are you sure you are checking the correct status? i.e. does your if condition ever evaluate to True. Start with the basics of code debugging like thht and work from there ... Also take a look at the FDMEE admin guide documentation for the getProcessStates function and I think that may shed some light on where you are going wrong :-)
On the line that has: if str(stat["IMPSTATUS"]) == "0": that looks like an o ("oh") and should it be a zero?
It was a login issue.
I was not including the Login statement 'smtpServer.login(username,password)' in my script for login into the SMTP server. Please find the updated script below:
import com.hyperion.aif.scripting.API as API
strFromAddress = "email@example.com"
strToAddress = ["firstname.lastname@example.org"]
strSMTPServer = "smtp.*******.com"
stat = fdmAPI.getProcessStates(fdmContext["LOADID"])
if str(stat["IMPSTATUS"]) == "0":
smtpServer = smtplib.SMTP(strSMTPServer,587)
smtpServer.sendmail(strFromAddress, strToAddress, strMessage)
fdmAPI.logInfo("Email Sent successfully")
except Exception, e:
fdmAPI.logInfo("Error :email not sent" + str(e))