Dave, the try...except clause you had highlighted was further down the code than where the error was occurring...Your error is telling you that the object e (which is a string - 'str') has no attribute message. This is possibly because message is the old method (deprecated as of Python 2.6).The new method goes something like this:import arcpy
try:
arcpy.ImportToolbox("popeye")
except Exception as e:
errormessage = str(type(e)) + '\n'
for arg in e.args:
errormessage += ' ' + str(arg) + '\n'
print errormessage
Firstly it gets the type of the error, then on a new line returns any arguments associated with the error...This should work:import arcpy
import smtplib
arcpy.env.overwriteOutput = True
try:
arcpy.CopyFeatures_management ('\\\\petrots\\data\\PAM\\PFS-Survey\\Data\\xxxxx.shp', '\\\\PETROTS\\arcgisproject\\PAM\\Clients\\PFSSurvey_v1\\Data\\xxx.shp')
except Exception as e:
errormessage = str(type(e)) + '\n'
for arg in e.args:
errormessage += ' ' + str(arg) + '\n'
print 'Operation failed, sending error message:\n', errormessage
to = 'me@email.com'
gmail_user = 'username'
gmail_pwd = 'password'
smtpserver = smtplib.SMTP("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo()
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'
print header
msg = header + errormessage
smtpserver.sendmail(gmail_user, to, msg)
print 'done!'
smtpserver.close()
Let me know how you get on.