<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Sending e-mail following completion of python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sending-e-mail-following-completion-of-python/m-p/207785#M15974</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Bill,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code works for me:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import smtplib&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#add the following lines to the end of your python script&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;to = '' #insert reciever email address (can be same as sender)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gmail_user = '' #your gmail sender address&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gmail_pwd = '' #your gmail password&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver = smtplib.SMTP("smtp.gmail.com",587) #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.ehlo() #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.starttls() #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.ehlo #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.login(gmail_user, gmail_pwd) #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;msg = header + '\n' + 'Your Python Script has now Completed!' #The completion message&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.sendmail(gmail_user, to, msg) #Sending the mail&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.close() #closing the mailserver connection&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Oct 2011 08:35:13 GMT</pubDate>
    <dc:creator>AlexOulton1</dc:creator>
    <dc:date>2011-10-21T08:35:13Z</dc:date>
    <item>
      <title>Sending e-mail following completion of python script</title>
      <link>https://community.esri.com/t5/python-questions/sending-e-mail-following-completion-of-python/m-p/207784#M15973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a rather long python scripting process that runs several hours. I would like to code into the script something that allows an e-mail message to be sent to me at the end of the program. I'm not looking to have any errors or logging sent, just a simple e-mail sent such as, 'The program has finished.' It would be the final step in the python program.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have looked on Python.org and tried a couple of examples, but nothing seems to work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 01:17:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sending-e-mail-following-completion-of-python/m-p/207784#M15973</guid>
      <dc:creator>BillBass</dc:creator>
      <dc:date>2011-10-21T01:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sending e-mail following completion of python script</title>
      <link>https://community.esri.com/t5/python-questions/sending-e-mail-following-completion-of-python/m-p/207785#M15974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Bill,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code works for me:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import smtplib&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#add the following lines to the end of your python script&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;to = '' #insert reciever email address (can be same as sender)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gmail_user = '' #your gmail sender address&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gmail_pwd = '' #your gmail password&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver = smtplib.SMTP("smtp.gmail.com",587) #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.ehlo() #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.starttls() #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.ehlo #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.login(gmail_user, gmail_pwd) #the technical stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;msg = header + '\n' + 'Your Python Script has now Completed!' #The completion message&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.sendmail(gmail_user, to, msg) #Sending the mail&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;smtpserver.close() #closing the mailserver connection&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 08:35:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sending-e-mail-following-completion-of-python/m-p/207785#M15974</guid>
      <dc:creator>AlexOulton1</dc:creator>
      <dc:date>2011-10-21T08:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sending e-mail following completion of python script</title>
      <link>https://community.esri.com/t5/python-questions/sending-e-mail-following-completion-of-python/m-p/207786#M15975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alex,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I try to use your code I get the following error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "email.py", line 26, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import smtplib&lt;BR /&gt;&amp;nbsp; File "c:\Python26\ArcGIS10.0\lib\smtplib.py", line 46, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import email.utils&lt;BR /&gt;&amp;nbsp; File "C:\GISData\Scripts\email.py", line 31, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpserver = smtplib.SMTP("smtp.gmail.com",587) #the technical stuff&lt;BR /&gt;AttributeError: 'module' object has no attribute 'SMTP'&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any clue on what is happening?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 17:12:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sending-e-mail-following-completion-of-python/m-p/207786#M15975</guid>
      <dc:creator>ScottBlankenbeckler</dc:creator>
      <dc:date>2011-11-30T17:12:20Z</dc:date>
    </item>
  </channel>
</rss>

