A simple e-mail notification system for Survey123 for ArcGIS v2

33621
107
01-22-2018 03:55 PM
IsmaelChivite
Esri Notable Contributor
19 107 33.6K

Back in November 2016, I published a blog post describing how to automate e-mail notifications against a Survey123 project. The idea was simple: A Python script that would trigger an email  every time a new survey is submitted. By scheduling the script to run unattended at certain time intervals, one could easily put together a simple e-mail notification system.

I want now to revisit this topic and share a new Python script, which takes care of some limitations of the first version. Specifically, the new script:

  1. Works against ArcGIS Enterprise in addition to ArcGIS Online
  2. Can be configured to either send one email for every newly added survey, or alternatively send one email for all new records added since the script was last launched.

While the Python script can be used as is, I really share it as a starting point from which you can write the exact logic that matches your needs. You may for example tweak the script to:

  • Format the e-mail notification following specific branding guidelines.
  • Extend the notification logic so the recipient of the email varies depending on data submitted.

Below are step by step instructions so you can configure this Python script with your own survey.

Preparing your computer to run the Python script

Technically, you can host the script in any computer that is able to run Python 3.x, however, you will want to select the host carefully. You will want  the script to run regularly and unattended, so you want to pick a computer that will reliably running 24x7 and constantly connected to your network.

In addition to Python 3.x, the script requires the 'requests' Python module installed.  If your computer already has ArcGIS Pro installed, you already have Python 3.x and the 'requests' module installed. However, ArcGIS Pro is not required to run this script.

Preparing your feature service

The Python script works against your survey's feature service. The script requires that your feature service has Editor Tracking enabled. By default, all feature services created by Survey123 have Editor Tracking enabled, so there is really nothing that you need to do extra. If  your survey is configured to work against a service from ArcGIS Server, then you will want to make sure  Editor Tracking is enabled, and if not, enable it manually.

If you do not enable Editor Tracking, the  script will generate an error  text file indicating that Editor Tracking needs to be enabled and will stop execution.

Downloading and configuring the Python script

Now you can download and configure the script as follows:

  1. Download the Detect Changes and Notify Python script v2 and its associated init.json file and save them together within a folder in your computer.
  2. Edit and save the init.json file. At the very least, you will need to change the properties highlighted  in blue below. 

{
   "email":{
     "recipients":["JohnSmith@acme.com"],
      "from":"acme@acme.com",
      "subject":"New features has been added to your service",
      "text":"Hi Team,\n\nYou are receiving this e-mail because features have been added in:\n",
  "server":["smtp.acme.com", "", "", ""],
"onemailflag":1
   },
   "service":{
      "portalURL":"https://www.arcgis.com",
"fsURL":"https://services2.arcgis.com/fJJEXNgxjn0dpNsi/arcgis/rest/services/service_20dc5e3eab3f4efab8fde88f6...",
      "fsLayerNum":0,
  "serviceuser":"yourusername",
"servicepw":"yourpassword",
      "fieldstoreport":["*"],
      "viewerMapLevel":19
   },
   "filenames":{
      "lasteditfile":"lastedit.json"
   }
}

  • recipients: This is the e-mail that will be receiving notifications. You can create an email alias if you want several people to receive the email.
  • from: This is the e-mail of the person/organization that is sending the e-mail. You can also set it to a DoNotReply email address.
  • server: This setting refers to your email server connection properties which are defined as a comma separated list of strings. 
    • The first parameter is the host of your email server which can be specified by hostname or IP address. It will look something like smtp.yourCompany.com for example or smtp.gmail.com
    • The second parameter is optional and defines the port where the SMTP server is listening. Common ports are 25 and 587 but it could really be any other port depending on how your mail server is configured.
    • The third and fourth parameters are also optional and are used to set a user and password to access your email server.
To  properly get the email  server connection properties, you will want to contact your IT department and describe what you are trying to  achieve as many email servers are configured with strict security  policies that will prevent the script from successfully connecting and  using your corporate e-mail server.  Folks in your IT department should  know how to give you the right hostname and port for  your email server.  Handing over the source code of the Python script may be of help too.

If you want to configure this script using your Gmail,  You will need to configure your Gmail account with 2-step verification, and then setup a Gmail App password.   Once you have done that, use your complete Gmail e-mail address as the  user (third parameter) and the App password for the fourth parameter.   When using Gmail you do not need to specify a port number, so simply type "" in the second parameter.
    • onemailflag: If you leave this parameter as 1, then an e-mail will be sent summarizing all records added since the Python script executed for the last time. If you switch the value to 0, then the script will trigger one e-mail for every record added.
    • portalURL: You only need to change this setting if working against ArcGIS Enteprise. You will want here the full https location of your portal including the Web Adaptor.
    • fsURL: This is the URL of your survey's feature service, which could be running in ArcGIS Online or ArcGIS Enterprise.
    • fsLayerNum: This is the index of the layer in the feature service that you want to monitor. If you want to check for changes in the main layer of your survey, leave it to 0. If you want to check for changes in the layer of a repeat, change the index accordingly.
    • serviceuser and servicepw: The ArcGIS credentials of a user with access to the feature service.

After saving changes to the init.json file, it is time to give the script  a quick test:

  1. Run the script once so it can capture the current state of your feature service.
  2. Submit one record to your feature service and run the script again.

If any errors occur during execution, an error text file will be created in the same folder where you saved the Python script.

Scheduling the script

The Windows operating system includes a simple utility called Task Scheduler. It is quite easy to setup. Once you have determined  when the script will be triggered for the first  time, you can repeat its  execution at regular intervals. For example, every 5 minutes. Obviously, the computer where  you setup the task will need to be running all the time, although you can configure the task to run regardless of who is logged in.

The configuration of tasks in the scheduler is pretty much self-explanatory, but here are some specific instructions that can save you some back and forth:

  1. General: Check the option to run with highest privileges and set the task to run even if you are not logged-in.
  2. Trigger: If you want to quickly test your task, you can simply select your task in the gallery and then hit Run in the Selected Item panel on the right.  When configuring the task for real, I suggest you select the startup trigger and that you also configure the task to run indefinitely every five or ten minutes or so.
  3. Actions: You will need to be particularly careful with this one. The Program/Script setting needs to point to the Python executable (Python.exe).
    • If using your own copy of Python, refer to the installation directory of Python where you will find Python.exe
    • If using Python from ArcGIS Pro, it will be under the Pro installation directory. For example: "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe"

You also need to indicate the location of your DetectChanges.py Python script as an argument. Do not forget to include the .py extension in the path. If the path to your DetectChanges.py file includes spaces, then you need to enclose the path with quotes. Lastly, set the 'Start in' property so it points to the  directory in which you are storing the DetectChanges.py file.

Beyond the basics

The technique described in this blog post is a bit rudimentary, but it  may do its job reasonably in some simple scenarios. You can manipulate the Python script to properly format the email message to be sent, and also to apply some logic to determine if a n email needs to be sent, and to who.  Since you are in 'Python land' already, you can get creative and import the arcpy.mapping module to do all sort of sophisticated things in the script. You can for example take the incoming feature added into your feature service and do a straight (buffer) or network distance (closest facility) search to determine who will be notified.

Differences between the original script and this one

There are a handful of differences between the original Python script published in November 2017 and this one.  For the most part, they are the same, but here are the key changes:

  • The most important difference is how changes in the feature layer are found. In the November 201 script the script exercises a new API introduced in ArcGIS Online to detect changes. This new API only works in ArcGIS Online (not in Enteprise) and it had to be enabled manually on the survey's feature service.  The latest version of the script, described in this  post, uses Editor Tracking. Editor Tracking is enabled by default in every feature service created by Survey123 for ArcGIS. Editor Tracking is compatible with ArcGIS Online feature services and also with ArcGIS Server feature services back to 10.1.
  • One email per feature or one per execution: The other  key difference is that in our November 201 version, it was not possible to easily configure the script to aggregate all changes in a single email. With this version, you can use the 'onemailflag' parameter in the init file to decide if you want to send one email per added record, or one email per execution of the script.

If you are already using the November 201 version of the script and want to switch to this one, I recommend that you copy the Python script and the new init file  into a separate folder. The init file is different, so pay attention to the new parameters introduced.

107 Comments
by Anonymous User
Not applicable

In case someone running into this issue; I was able to resolve "not finding json file" through Task Scheduler by changing json to a simple text file.

NolitaLavoie1
New Contributor II

Did you ever get a fix for this? I had the same error message. This error only appeared when trying to set this email notification on a ArcGIS Server Feature Service registered through ArcGIS Online for use in Survey123. Since this Feature Service writes to an Oracle Feature Class, I will default to an oracle email trigger for this Survey123 notification.

HelderVieira
New Contributor

Thank you very much.  Has anyone customized the script to add attribute information to the subject line?

AmyStorey
New Contributor II

Hello,

I keep getting this error when I try to run, I am very new to this, can anyone offer any assistance?

Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
 RESTART: N:\SDB053900_MIRA COSTA\GIS\MCC\scripts\DetectEdits\DetectEdits.py
Traceback (most recent call last):
  File "N:\SDB053900_MIRA COSTA\GIS\MCC\scripts\DetectEdits\DetectEdits.py", line 340, in <module>
    main(configfilename)
  File "N:\SDB053900_MIRA COSTA\GIS\MCC\scripts\DetectEdits\DetectEdits.py", line 68, in main
    sinfo = siresult.json()
  File "C:\Users\storey\AppData\Local\ESRI\conda\envs\my_arcgispro-py3\lib\site-packages\requests\models.py", line 884, in json
    self.content.decode(encoding), **kwargs
  File "C:\Users\storey\AppData\Local\ESRI\conda\envs\my_arcgispro-py3\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\storey\AppData\Local\ESRI\conda\envs\my_arcgispro-py3\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\storey\AppData\Local\ESRI\conda\envs\my_arcgispro-py3\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
>>>

JamesTedrick
Esri Esteemed Contributor

Hi Amy,

Can you check the config file's JSON formatting at a site like https://jsonlint.com ?  That would be a common cause for  a JSON decode error.

AmyStorey
New Contributor II

I figured it out, it ended up being just that I had not added a passcode for my gmail account. Thanks though for your reply, I am not a scripter, but so satisfying to finally have it all set up and working. Thanks for posting!! My next task will be to try and modify it to email when a certain field is updated as well, right now it only sends the email when a new feature is added. I am reading through all the posts tonight to see if I can figure it out!

Amy Storey, LEED®AP | GIS Analyst | NV5<http://www.nv5.com/>

15092 Avenue of Science, Suite 200 | San Diego, CA 92128 | P: 858.385.2175 | C: 619.261.4243 | F: 858.385.0400

Electronic Communications Disclaimer<http://www.nv5.com/contact-us/electronic-communications-disclaimer/>

LinaNguyen
New Contributor

Good morning, 

I'm working with my IT Department and we keep getting the same error message:

"An email error occurred (in sendMail) while attempting to connect to: 
Please ensure your Mail Server Host and port are set correctly in your Init.json file"

IT wants to know, where does the script execute from? Is it from our server where the script is stored or from AGOL?

Thank you for your help!

- Lina

SarahDickson
New Contributor

Hi! I'm really excited to use this script, but the download link just brings me to a page that loads indefinitely. Is this script still supported/available?

BrandonArmstrong
Esri Regular Contributor

Hi Sarah,

Can you please try using another browser and see if that resolves the issue?  I just downloaded the script using Google Chrome without issue.  If you are still having problems using a new browser, let me know and we can exchange emails addresses so that I can send it to you.

Best,

Brandon

SarahDickson
New Contributor

Thanks Brandon, that worked! I had been using Google Chrome, but for some reason Firefox worked instead. 

JamesTedrick
Esri Esteemed Contributor

Hi Sarah,

You should still be able to access the script.  You should also be able to go over to ArcGIS Online and search for ti if the direct link doe not work.

JamesTedrick
Esri Esteemed Contributor

Hi Lina,

The script is running from the computer you enter the python command on.  Just to check, you did update the init.json file with setting appropriate for your mail server?

LinaNguyen
New Contributor

Hi James,

Yes, we updated the init.json file and tested with hostname or IP address, port, and user and password but nothing was successful. I'll keep digging and see if IT can help me more. 

Thank you!

- Lina

JohnStowell
New Contributor III

Hi all,

Here's a script I created for automating Survey123 report creation (based on a .docx report template) and emailing a copy of the .docx report to recipients (the recipient email is taken from the relevant survey submission). It is intended to be ran daily, grabbing the submissions from the last 24 hrs.

GitHub - nzjs/Automated-Survey123-Reports: A tool to automate Survey123 Report creation & emailing s... 

AlexP_
by
Occasional Contributor III

Hello, James TedrickIsmael Chivite

Would visual cron work instead window task scheduler? Please advise. 

Thank you,

Alex

AlexP_
by
Occasional Contributor III

I got an ERROR when it is generated. Please advise. See screenshots. Thank you.

Script:

ArcGIS Server Manager: I am not sure if this has to do with this.

CorrynSmith2
New Contributor III

I was having the same issue, Sarah.  Firefox worked for me as well. 

JamesTedrick
Esri Esteemed Contributor

Hi Alex, 

Yes, a third party task scheduler like VisualCron would be fine.

JamesTedrick
Esri Esteemed Contributor

Hi Alex,

There isn't enough information in the Script screenshot to understand the issue.  Based on the ArcGIS Server Manager, it looks like one possible issue is with regard to service setup - can you test the queries that the script is making to identify the features?

CorrynSmith2
New Contributor III

I really like how this script works.  For my survey in Survey123, I am not asking the surveyors for a geolocation/point on a map, so I'm not updating a feature service.  I still want to send an email out when the form is filled out. Any advice on how and where I should add the survey ID? Thanks!

IsmaelChivite
Esri Notable Contributor

Hi Corryn Smith‌. This should not make much of a difference. Simply change the fsLayerNum property in the json configuration file accordingly and let  the script run. Use the ArcGIS services directory to figure out what is the layer index of your table in the feature service.

AlexP_
by
Occasional Contributor III

Please see this whole screenshot. I tested it again on the same layer with different feature and it came thru. How can I resolve it when this happened below if it doesn't come thru?  Thank you.

JamesTedrick
Esri Esteemed Contributor

Hi Alex,

Unfortunately, the message does not detail why the email failed - it looks like the script is not setup to log out the email error, only report which object it failed on.

Probably unrelated, but one question I have is why are you doing this on the proxied AGOL item instead of the original feature service endpoint?

AlexP_
by
Occasional Contributor III

This is a testing purpose. It is secured service to store credential.

JAVIERVARA_SANZ
Occasional Contributor II

Good morning John.

 

Thanks a lot for this post.

 

I’m trying to use this code but keep getting the following error:

 

  File "C:\Users\...\AGOLPRO\lib\site-packages\arcgis\apps\survey123\_survey.py", line 227, in generate_report

    "featureLayerUrl" : self._ssi.layers[0]._url.replace("_fieldworker", ""), AttributeError: 'NoneType' object has no attribute 'layers'

 

Not sure if this makes sense, but I don’t have a layer or rest end point containing “fieldworker”.

 

Please advise.

 

Thanks again.

Javier

JohnStowell
New Contributor III

JAVIER VARA SANZ

Can you start a thread on the Issues portion of the GitHub page? Happy to work through the issue with you there.

PaulGiroux1
New Contributor III

Will this work with a Feature Service we're using with Collector.  I wanted to check with the community before we dug in too deep.

JamesTedrick
Esri Esteemed Contributor

Hi Paul,

This script should work with any feature service that has the Editor Tracking enabled. 

GavinRunyon
New Contributor III

Has anyone tried modifying this script and publishing it as a Web Tool? It would be great to use this as an executable script tied to a widget in Web Appbuilder.

MarkBennett
Occasional Contributor

Hi Ismael, 

In addition to using the Survey123 for many of our clients, I recently also started to use Citizen Problem Reporter app. In that app (and others) , there is also a email notification functions. I believe that also the "send-email" function used in different AGOL apps, the underlying method is the same. I have encountered SMTP server connection problem, but I could not found much posts in that community. Therefore, I am trying it here in this post.

I have set the SMTP server perimeters as the following in the json configuration file:

"email settings": {
  "smtp username": "ming800@gmail.com",
  "smtp server": "smtp.gmail.com",
  "smtp password": "password",
  "reply to": "kzwierschke@bennettandwilliams.com",
  "from address": "Ming800@gmail.com",
  "use tls": true,
  "substitutions": null
 },

The following call in python script with give a few trials (about 15 seconds) and return an exception with an error message.

with EmailServer(server, username, password, tls) as email_server:

The Error message: 

(421, b'Cannot connect to SMTP server 104.47.13.33 (104.47.13.33:25), connect error 10060')2019-07-02 11:07:59.829823

It seems that it also tried to connect a number of alternative IPs but returns the same error.

In addition, I also tried smtp.live.com for hotmail and it returns a similar error message.

Do you, or anyone, knows what I did wrong?

My next try is to using your script!

Thanks,

Ming

by Anonymous User
Not applicable

Script works great but the report is giving me the time in UTC and I need it in PST. Any idea on how to correct this?

by Anonymous User
Not applicable

This is because the lasteditdatestring variable is in UTC since time is stored in UTC online. It's important for it to stay in UTC time for the query, but later you can convert it (like right before the writemessages() function). I would do this to convert it:

utc_unaware = datetime.datetime.strptime(lasteditdatestring, dateformat) # Convert to datetime

utc_aware = pytz.utc.localize(utc_unaware) # Make it timezone aware

new_time = utc_aware.astimezone(pytz.timezone("US/Pacific")) # Convert it to PST

lasteditdatestring = datetime.datetime.strftime(new_time, dateformat) # Set the string to the new time in the same format

I would insert this just before line 151 where writemessages() is called near the end of the main() function. One thing to note is that you'll have to import pytz. One thing I'm unsure of is if it'll take care of daylight savings.

Hope this helps.

Dan

by Anonymous User
Not applicable

That corrected one of the dates in the email but this did not correct the dates in the attributes sent in the email alert.

by Anonymous User
Not applicable

Oh yeah, I overlooked that part. 

At line 205 in the original script, you'll notice;

val = datetime.datetime.utcfromtimestamp(atts / 1000.).strftime('%Y-%m-%d %I:%M:%S %p UTC')

Replace that with;

dt_init = datetime.datetime.utcfromtimestamp(atts / 1000.) # Convert Esri Date to Python datetime

dt_aware = pytz.utc.localize(dt_init) # Make it timezone aware

new_time = dt_aware.astimezone(pytz.timezone("US/Pacific")) # Convert it to PST

val = datetime.datetime.strftime(new_time, '%Y-%m-%d %I:%M:%S %p PST') # Set the string to the new time in the same format

This should fix it all. It's just an issue with a bit of formatting and the fact that all dates are stored in UTC online. Just a quick timezone conversion and format it as a string, and bam. Just like with last time though, I'm not really sure if this covers daylight savings.

by Anonymous User
Not applicable

Thanks again!

JaredPilbeam2
MVP Regular Contributor

Amy,

I was wondering where you added your app password? I have gmail and have created an app pasword, but I'm a little confused as to what I should do with it.

ManjulShrestha
New Contributor

I am newbie to python. I was able to run this script and it looks like the script ran successfully but it never sent email to the recipients. Any advice what went wrong on this?

This is the message I got after running the script.

>>>

 RESTART:\\cwaxpersona\PersonaUsers\mshrestha\Desktop\ManjulShrestha\EmailNotifyScripts\DetectEdits.py

CreationDate>'09/17/2019 04:11:46.527000 PM'

Outfields = *

 

Elapsed time: 0:00:01.218176

Process Complete

>>> 

Thanks,

MonikaSamorajska1
New Contributor

Hello everyone,
I uses GIS software, but I don't know Python very well. It is literraly my begining with Python scripting, but the explanation is very clear and I was able to change eveything what I had to change. Unfortunatelly i've got an issue when I run the 'DetectEdits.py' script.

I've received a meesage below:

I don't understand it, because I have to .json file in the same folder as the DetectEdits.py, I double cheked all information in the .json file and I think the information are correct.

Oo I should add that I am trying to use this script for "Collector for ArcGIS" application not for "Survey 123".

Any suggestions or ideas?

I would be gratefull for any ideas or suggestions.

Thanks in advance,

Monika

JamesTedrick
Esri Esteemed Contributor

Hi Monika,

Is your command prompt in the same directory as the 'DetectEdits.py' file?  If you look at the bottom of the file (line 338) you can see that the son file is specified without any directories - it should be in the same directory as your command prompt when you run it.

MonikaSamorajska1
New Contributor

Hi James,

It turned out that I used a wrong version of Python.

Now I am having a different issue when I try to run the 'DetectEdits.py' script.

I receive below message:

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\DetectEdits.py"
Traceback (most recent call last):
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\DetectEdits.py", line 340, in <module>
    main(configfilename)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\DetectEdits.py", line 63, in main
    servicetoken = getToken(sharingurl, cfg['service']['serviceuser'],
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\DetectEdits.py", line 257, in getToken
    rjson = r.json()
  File "D:\DATA\m.samorajska.EGIS\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "D:\DATA\m.samorajska.EGIS\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "D:\DATA\m.samorajska.EGIS\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\DATA\m.samorajska.EGIS\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am using Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Below there is a "initDetectEdits.json" file which I updated with my credentials and feature service:

{
   "email":{
      "recipients":["monika.samorajska-int@egis.fr"],
      "from":"DoNoTReplay",
      "subject":"New features has been added to your service",
      "text":"Hi Team,\n\nYou are receiving this e-mail because features have been added in:\n",
      "server":["smtp.egis.fr", "25", "", ""],
      "onemailflag":0
   },
   "service":{
      "portalURL":"https://egisenv.maps.arcgis.com/home/groups.html",
      "fsURL":"https://arcgis.egis.fr/arcgis/rest/services/MMA_CSQ/CSQ_RAM_FRACAS_DesignSys_Equipment_Pt/FeatureSer...",
      "fsLayerNum":0,
      "serviceuser":"m.samorajska",
      "servicepw":"xxx",
      "fieldstoreport":["*"],
      "viewerMapLevel":19
   },
   "filenames":{
      "lasteditfile":"lastedit.json"
   }
}

I should also add that the feature service is stored in GDB Enterprise and publish in AGOL via AGS.

I would be gratefull for any help with the script.

Thanks in advane.

Monika

by Anonymous User
Not applicable

Hi James,

I am using Python 3.6.8 and am getting the same error, "ImportError: cannot import name EmailMessage". I have ArcGIS Pro but am using the Python 3 Command Prompt to run the script. What am I missing?

Thanks!

JamesTedrick
Esri Esteemed Contributor

Hi May,

Can you confirm the version of Python running in the command line?  If you multiple installations (say, from ArcMap and ArcGIS Pro), you may be running a different version.

by Anonymous User
Not applicable

Hi James,

Thanks for getting back to me!! I got past my initial error regarding the “ImportError: cannot import name EmailMessage” but now I am getting a JSONDecodeError (see attached). Can you help me with this? I am running on Python 3.6.8. Also, I only have ArcGIS Pro and ArcGIS Maps Office plug-in.

Thanks so much,

May

JamesTedrick
Esri Esteemed Contributor

Hi May,

Unfortunately, the attachment did not make the post (blog posts don't allow for attachments).  Can you copy/paste the error you are seeing?

by Anonymous User
Not applicable

Here is the error I am getting. Thanks.

by Anonymous User
Not applicable

The issue has been resolved. Please disregard. Thank you.

HelderVieira
New Contributor

Hi,

i would like to use an additional parameter when sending out emails.

Can this be done? if so, how.

Thanks.

by Anonymous User
Not applicable

What additional parameter would you like added? I can look into it.

AmeWunderle
New Contributor III

Hi James and Lina,

I am having the same issues. We updated the json file to the appropriate host/port, no authentication as it is not required when sent internally. Still having the same error message.

Wondering if this was ever resolved Lina? Any suggestions James?

We were able to get the script working from gmail back in September 2019 and that is also not working anymore, offering the same error although the parameters haven't changed (within the original gmail init.json file).

As a note host and port have been verified as accessible from the server we are running the script from.

Any suggestions would be very welcome!

AmeWunderle
New Contributor III

After spending more time walking through the code and adding a traceback to the error logging code, I realized it was a TLS encryption problem because the outgoing mail server didn't support TLS. As the email is being sent internally, I commented out server.starttls() and it worked perfectly. I wouldn't recommend this work around over external network connections.