Hi Chandreyee,
If you are tracking edits within the hosted feature service, you could have Windows Task Scheduler check the service at a given time interval (i.e. once an hour) and check for any new features that were added within the last hour.
Below is an example on how to do this. The service is tracking edits, where new features are recorded in a field called 'created_date'. The script queries the service and checks this field and compares it to the current time (minus one hour). If the time is greater than the current time, it will send an e-mail of the OBJECTIDs of the new features.
import urllib2, json, urllib, datetime, time, smtplib
from datetime import timedelta
oidList = []
URL = 'http://services.arcgis.com/Fz6JUji5ArUSDM/arcgis/rest/services/Airports/FeatureServer/0/query'
params = {'f': 'pjson', 'where': "1=1", 'outfields' : 'OBJECTID, created_date', 'returnGeometry' : 'false'}
req = urllib2.Request(URL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
for feat in data['features']:
createDate = feat['attributes']['created_date']
createDate = int(str(createDate)[0:-3])
t = datetime.datetime.now() - timedelta(hours=1)
t = time.mktime(t.timetuple())
if createDate > t:
oidList.append(feat['attributes']['OBJECTID'])
FROM = 'sender@hotmail.com'
TO = ['receiver@yahoo.com']
SUBJECT = 'New Feature Added'
TEXT = "Features with OBJECTIDs " + str(oidList) + " were added."
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
smtpObj = smtplib.SMTP(host='smtp.hotmail.com', port=25)
smtpObj.sendmail(FROM, TO, message)
print "Successfully sent email"
smtpObj.quit()