[GIS] Automatically emailing interim results from ModelBuilder

arcgis-10.0arcpymodelbuilder

I want to get ModelBuilder to email me the results of processes at certain stages so that if there are issues I can remotely login and deal with them as I do with python scripts. I have a python based tool to email the results but don't see a way to get results from individual processes. You can right-click on a process in ModelBuilder and view results but how can I get this info to be passed into the email script?

Worst case scenario – I guess I can export the model to python and add the emailer script but is there an easier way?

enter image description here

Model Code -this is a simple model to test. The main model to use this on will run over a weekend or more as the raster-polygon take about 6 hours for some tiles.

# ---------------------------------------------------------------------------
# model_emailstatus.py
# Created on: 2011-10-11 16:28:25.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("D:/SCRATCH/Projects/106/Toolbox.tbx")


# Local variables:
Key_Resource_Area_shp = "O:\\2011\\11\KeyResourceArea.shp"
Key_Resource_Separation_Area_shp = "O:\\2011\\1121\SeparationArea.shp"
Message = ""

This is what I want to fill…in python it would be just Message = arcpy.GetMessages() but what does the same thing in model builder?

Email = "georgec@xxxxxxxx"
Success = ""

How do I fill this with true/false depending on if the merge tool is successful or not?

KeyResourceArea_Merge = "C:\\Users\\georgec\\Documents\\ArcGIS\\Default.gdb\\KeyResourceArea_Merge"

# Process: Merge
arcpy.Merge_management(<snip>)

# Process: EmailStatus
arcpy.gp.toolbox = "D:/SCRATCH/Projects/106/Toolbox.tbx";
# Warning: the toolbox D:/SCRATCH/Projects/106/Toolbox.tbx DOES NOT have an alias. 
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.EmailStatus(...) with arcpy.EmailStatus_ALIAS(...)
arcpy.gp.EmailStatus(Message, Email, Success)

Best Answer

I'd probably ditch ModelBuilder, or at least call your models from Python, and use the logging module with an SMTPHandler to email you any critical messages.