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:
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?
Unfortunately, you won't be able to send an e-mail using smtplib in AGOL Notebooks.
Hi @JakeSkinner , I can't go the route of using gis.users.send_notification becasue the account i use to connect to arcgis and send emails wont get the admin rights.
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?