Hello again. I want to send a simple e-mail to members from an ArcGIS Online Group. A general version of the script is provided at the bottom. PLEASE help me if you know how to format the email_body for the (it appears) smtp message.
My main concern is FORMATTING the email_body because the message protocol clearly does not recognize Python string delimeters - the newlines and tabs are not being produced, just one long sentence basically.
I have found really helpful resources for more heavy-duty automated messaging (for instance: Send Email When a Feature is Added to an ArcGIS Online Hosted Feature Service ) BUT it does not appear I can access e-mails of Group members, so I am confined to the Arcgis Python API using the Group.notify method.
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> Group
<SPAN class="comment token"># get gis object</SPAN>
my_gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN>username <SPAN class="operator token">=</SPAN> <SPAN class="operator token"><</SPAN>my_username<SPAN class="operator token">></SPAN><SPAN class="punctuation token">,</SPAN> password <SPAN class="operator token">=</SPAN> <SPAN class="operator token"><</SPAN>my_password<SPAN class="operator token">></SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Group User Info: dict with keys - owner, admins, users</SPAN>
my_group <SPAN class="operator token">=</SPAN> Group<SPAN class="punctuation token">(</SPAN>my_gis<SPAN class="punctuation token">,</SPAN> <SPAN class="operator token"><</SPAN>group_id_number<SPAN class="operator token">></SPAN><SPAN class="punctuation token">)</SPAN>
members_dict <SPAN class="operator token">=</SPAN> my_group<SPAN class="punctuation token">.</SPAN>get_members<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># give me list of user names from group</SPAN>
group_users <SPAN class="operator token">=</SPAN> members_dict<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'users'</SPAN><SPAN class="punctuation token">]</SPAN>
subject <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Changes and updates to group'</SPAN>
signature <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Zach <Lastname\>nGIS Specialist\n(123) 456-7890\tmyemail.com'</SPAN>
email_body <SPAN class="operator token">=</SPAN> <SPAN class="string token">'''Hi everybody,\n\nWe have changed some content and protocol
updated and added metadata to the existing datasets -
feature layers and shapefiles - and did other stuff.
\n\nFeel free to contact me if you have questions.
\n\n'''</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>signature<SPAN class="punctuation token">)</SPAN>
my_group<SPAN class="punctuation token">.</SPAN>notify<SPAN class="punctuation token">(</SPAN>group_users<SPAN class="punctuation token">,</SPAN> subject<SPAN class="punctuation token">,</SPAN> email_body<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'email'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>