Skip to main content
Added code formatting.
Source Link
Paul
  • 11.6k
  • 1
  • 30
  • 47
import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)
import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)
import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)
import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)
Fixed IDLE and added link
Source Link
Aaron
  • 51.8k
  • 29
  • 157
  • 321

How about e-mailing yourself when the model is finished? Make sure to set your phone to give you a tone when you receive the e-mail sent via the attached Python script. This is designed to be run as a script tool in ModelBuilder. If you are not familiar working with script tools, follow these instructions. Please not that this is configured to work with gmail. The tool is designed to work as follows (note the precondition attaching the bufferedPoints variable and the sendEmail script tool):

enter image description here


import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)

Instructions for creating the script tool:

Create the script

  1. Open IDLIDLE > File > New Window
  2. Copy and paste script on this post to the new window
  3. Save as > "SendEmail.py"

Create the script tool

  1. Right-click on a folder > New > Toolbox (This is where the script tool will be located)
  2. Right-click toolbox > Add > Script...
  3. Fill in Name, Lable, Description and check "Store relative path...."
  4. Hit Next
  5. Add the script you created "SendEmail.py"
  6. Hit Next
  7. Fill in the parameters exactly as in attached figure.
  8. Hit Finish
  9. Locate new tool in tool box and use as you would any other tool in ModelBuilder

enter image description here

How about e-mailing yourself when the model is finished? Make sure to set your phone to give you a tone when you receive the e-mail sent via the attached Python script. This is designed to be run as a script tool in ModelBuilder. If you are not familiar working with script tools, follow these instructions. Please not that this is configured to work with gmail. The tool is designed to work as follows (note the precondition attaching the bufferedPoints variable and the sendEmail script tool):

enter image description here


import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)

Instructions for creating the script tool:

Create the script

  1. Open IDL > File > New Window
  2. Copy and paste script on this post to the new window
  3. Save as > "SendEmail.py"

Create the script tool

  1. Right-click on a folder > New > Toolbox (This is where the script tool will be located)
  2. Right-click toolbox > Add > Script...
  3. Fill in Name, Lable, Description and check "Store relative path...."
  4. Hit Next
  5. Add the script you created "SendEmail.py"
  6. Hit Next
  7. Fill in the parameters exactly as in attached figure.
  8. Hit Finish
  9. Locate new tool in tool box and use as you would any other tool in ModelBuilder

enter image description here

How about e-mailing yourself when the model is finished? Make sure to set your phone to give you a tone when you receive the e-mail sent via the attached Python script. This is designed to be run as a script tool in ModelBuilder. If you are not familiar working with script tools, follow these instructions. Please not that this is configured to work with gmail. The tool is designed to work as follows (note the precondition attaching the bufferedPoints variable and the sendEmail script tool):

enter image description here


import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)

Instructions for creating the script tool:

Create the script

  1. Open IDLE > File > New Window
  2. Copy and paste script on this post to the new window
  3. Save as > "SendEmail.py"

Create the script tool

  1. Right-click on a folder > New > Toolbox (This is where the script tool will be located)
  2. Right-click toolbox > Add > Script...
  3. Fill in Name, Lable, Description and check "Store relative path...."
  4. Hit Next
  5. Add the script you created "SendEmail.py"
  6. Hit Next
  7. Fill in the parameters exactly as in attached figure.
  8. Hit Finish
  9. Locate new tool in tool box and use as you would any other tool in ModelBuilder

enter image description here

Added more details to address OP's comments
Source Link
Aaron
  • 51.8k
  • 29
  • 157
  • 321

How about e-mailing yourself when the model is finished? Make sure to set your phone to give you a tone when you receive the e-mail sent via the attached Python script. This is designed to be run as a script tool in ModelBuilder. If you are not familiar working with script tools, follow these instructions. Please not that this is configured to work with gmail. The tool is designed to work as follows (note the precondition attaching the bufferedPoints variable and the sendEmail script tool):

enter image description here


import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)

Instructions for creating the script tool:

Create the script

  1. Open IDL > File > New Window
  2. Copy and paste script on this post to the new window
  3. Save as > "SendEmail.py"

Create the script tool

  1. Right-click on a folder > New > Toolbox (This is where the script tool will be located)
  2. Right-click toolbox > Add > Script...
  3. Fill in Name, Lable, Description and check "Store relative path...."
  4. Hit Next
  5. Add the script you created "SendEmail.py"
  6. Hit Next
  7. Fill in the parameters exactly as in attached figure.
  8. Hit Finish
  9. Locate new tool in tool box and use as you would any other tool in ModelBuilder

enter image description here

How about e-mailing yourself when the model is finished? Make sure to set your phone to give you a tone when you receive the e-mail sent via the attached Python script. This is designed to be run as a script tool in ModelBuilder. If you are not familiar working with script tools, follow these instructions. Please not that this is configured to work with gmail. The tool is designed to work as follows (note the precondition attaching the bufferedPoints variable and the sendEmail script tool):

enter image description here


import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)

How about e-mailing yourself when the model is finished? Make sure to set your phone to give you a tone when you receive the e-mail sent via the attached Python script. This is designed to be run as a script tool in ModelBuilder. If you are not familiar working with script tools, follow these instructions. Please not that this is configured to work with gmail. The tool is designed to work as follows (note the precondition attaching the bufferedPoints variable and the sendEmail script tool):

enter image description here


import smtplib, os, arcpy
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders

# Fill in the necessary blanks here
gmail_user = sys.argv[1]
gmail_pwd = sys.argv[2]

# The parameters
to = sys.argv[3]
subject = sys.argv[4]
text = sys.argv[5]

def mail(to, subject, text):
    msg = MIMEMultipart()

    msg['From'] = gmail_user
    msg['To'] = to
    msg['Subject'] = subject

    # Attaches a text message to the e-mail
    msg.attach(MIMEText(text))

    mailServer =smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, to, msg.as_string())
    mailServer.close()

mail(to, subject, text)

Instructions for creating the script tool:

Create the script

  1. Open IDL > File > New Window
  2. Copy and paste script on this post to the new window
  3. Save as > "SendEmail.py"

Create the script tool

  1. Right-click on a folder > New > Toolbox (This is where the script tool will be located)
  2. Right-click toolbox > Add > Script...
  3. Fill in Name, Lable, Description and check "Store relative path...."
  4. Hit Next
  5. Add the script you created "SendEmail.py"
  6. Hit Next
  7. Fill in the parameters exactly as in attached figure.
  8. Hit Finish
  9. Locate new tool in tool box and use as you would any other tool in ModelBuilder

enter image description here

Added more details
Source Link
Aaron
  • 51.8k
  • 29
  • 157
  • 321
Loading
Source Link
Aaron
  • 51.8k
  • 29
  • 157
  • 321
Loading