Hi,I need help with a Python script requirement.
The setup:
The task:I need to write a script to:
What I’ve tried:
Questions:
Any advice or ideas are appreciated!
@ChallagundlaSindhuraITS is your Survey123 feature service hosted in AGOL? Here is an example script on how to send an e-mail for an AGOL hosted feature service:
https://community.esri.com/t5/python-documents/send-email-when-a-feature-is-added-to-an-arcgis/ta-p/920545
I recommend configuring Windows Task Scheduler to execute this script on a server that has ArcGIS Pro install, and will not be turned off.
Thank You @JakeSkinner for a quick reply!!
Yes, the Survey123 form developed by user is in AGOL. The data is in AGOL. I access the data from the feature layer using a API call.
I will try the script you have suggested for emails. The .py script i write cannot be hosted on my side. Is hosting the .py script on esri cloud possible? i am asking since the script uses two feature layers developed by the user and nothing related to the application on my side.
@ChallagundlaSindhuraITS yes, you can use AGOL Notebooks to host the script. Below is an example on how to send an e-mail.
from arcgis.gis import GIS # Variables username = 'jskinner_rats' password = '********' # Connect to AGOL gis = GIS('https://www.arcgis.com', username, password) # Create list of users to send e-mail to userList = [] user = gis.users.get('jskinner_rats') userList.append(user) # Construct message and send messageSubject = 'This is a test message from AGOL' messageMessage = 'This is the plain text message that we are sending.' gis.users.send_notification(userList, subject = messageSubject, message = messageMessage, type = 'email')
Hi @JakeSkinner ,
I have tried this code snippet , but the account i use to connect to doesnt have permissions. Error: You do not have permissions to access this resource or perform this operation.(Error Code: 403)
gis = GIS('https://www.arcgis.com', username, password)
Do you have any suggestions to send emails using smtplib?
Thank You JakeSkinner, Is it possible to send emails from AGOL notebooks to the out of organisation emails(not GIS users)? Also can we send text messages to the phonenumbers from AGOL notebooks? Please advice. Thanks again
I would recommend using a local server that has ArcGIS Pro to execute your scripts. You can then leverage the smtplib module and send e-mails/texts.
Thank You JakeSkinner , I dont have ArcGIS Pro software, Is there a way i can do with Arcgis API for Python to send emails/texts?
@ChallagundlaSindhuraITS no, not without an Admin account.
Thank You @JakeSkinner , I dont have a ArcgisPro lisence to go explore that route, but someone from the other team suggested that Email's are usually handled using web hooks via Microsoft Power Automate. I am not the person who created the Survey123 Spill form, but can i create webhook or attach a .py script to assign a spill and send email notifications?
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.