Â
Â
I am trying to set my workspace to send an email using a shutdown python script.Â
For doing so, I used the following Python script found on one of the Safe articles:Â
Â
Â
import smtplib, fmeobjectsÂ
ÂÂ
to =Â FME_MacroValuesa'EmailTo']Â
gmail_user =Â FME_MacroValues_'GmailUser']Â
gmail_pwd =Â FME_MacroValuesM'Password']Â
Subject =Â FME_MacroValues 'SuccessSubject']Â
FailSubject =Â FME_MacroValuesÂ'FailSubject']Â
Emailfrom =Â FME_MacroValues 'EmailFrom']Â
Jobs =Â FME_MacroValuesb'JOBID']Â
Â
FeaturesWritten = str(FME_FeaturesWritten)Â
Â
status = FME_StatusÂ
if status == 0:Â
   Subject = FailSubjectÂ
   Message = 'Workspace Failed'  ÂÂ
else:Â
   Message = 'Workspace Successful. Resulting *.dwg Can Be Located At C:\\Temp'Â
Â
smtpserver = smtplib.SMTP("smtp.gmail.com",587)Â
Â
smtpserver.ehlo()Â
smtpserver.starttls()Â
smtpserver.ehloÂ
smtpserver.login(gmail_user, gmail_pwd)Â
header = 'To:' + to + '\\n' + 'From: ' + Emailfrom + '\\n' + 'Subject:' + Subject +'\\n'Â
print headerÂ
msg = header + '\\n' + Message + '\\n\\n'Â
smtpserver.sendmail(gmail_user, to, msg)Â
print 'done!'Â
smtpserver.close()Â
Â
Â
This code works fine, but what I need to do is set the email destination ("to" variable) to an attribute called _Email_submitter.Â
But when I try to do so, the translation fails.Â
I setting the variable like this:Â
Â
feature.getAttribute("_Email_submitter") =Â emailÂ
to =Â emailÂ
Â
This is the only part in the entire code that is changed, but for some reason its causing the translation to fail.Â
Â
I am not sure with I am having a problem retriving the attribute value (the list have only one value) or if is not possible to set an attribute value as the email destination.Â
Â
Â
Thanks,Â
Gabriel