<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Email list of connected users needs character stripping in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368632#M29049</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jennifer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could define a list of usernames you wish to &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;exclude,&lt;/SPAN&gt; and do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;userNames = [u.Name for u in userList]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;exclusion_list = ["Josh", "Jennifer"]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;for name in userNames:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if name in exclusion_list:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; userNames.remove(name)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&lt;SPAN&gt;emailList = [name + &lt;/SPAN&gt;&lt;A class="" href="mailto:'@myorganization.com"&gt;'@myorganization.com&lt;/A&gt;&lt;SPAN&gt;' for name in userNames]&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;-Josh&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Oct 2019 12:07:51 GMT</pubDate>
    <dc:creator>GeoJosh</dc:creator>
    <dc:date>2019-10-11T12:07:51Z</dc:date>
    <item>
      <title>Email list of connected users needs character stripping</title>
      <link>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368629#M29046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="font-size: 15px; font-family: verdana, geneva, sans-serif; "&gt;Full disclaimer: I'm not a programmer and understand the bare minimum&amp;nbsp;of python&amp;nbsp;just to get by. I want to learn more but don't have anyone to help with bouncing ideas or finding solutions. Hence, I'm here humbling requesting your help.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; font-family: georgia, palatino, serif;"&gt;I've been working off of&amp;nbsp; #&lt;A href="http://desktop.arcgis.com/en/arcmap/10.6/manage-data/geodatabases/using-python-scripting-to-batch-reconcile-and-post-versions.htm"&gt;Use Python scripting to batch reconcile and post versions&lt;/A&gt;. However, I have this problem were the list of user names comes back with double quotes and the domain plus user name. Ex. "domain\user name".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; font-family: georgia, palatino, serif;"&gt;So when it adds the full email address it comes out as: &lt;STRONG&gt;"domain\user name"&lt;/STRONG&gt;@myorganiztion.com. Then of course it can't send an email because of the quotes and domain. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;EM&gt;&lt;STRONG style="text-decoration: underline; "&gt;How do I eliminate the double quotes and domain from the userNames list?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 15px;"&gt; I tried&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: georgia, palatino, serif; font-size: 15px;"&gt; &lt;SPAN style="font-family: 'trebuchet ms', geneva, sans-serif;"&gt;.strip, &lt;SPAN style="font-family: georgia, palatino, serif;"&gt;as well as,&lt;/SPAN&gt; .format &lt;SPAN style="font-family: georgia, palatino, serif;"&gt;and to no avail.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;Thanks in advance.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy, os, csv, smtplib, ssl&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;SDE_Workspace = r"\\....DEFAULT.sde"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;#Build list of connected users&lt;/EM&gt;&lt;BR /&gt;userList = arcpy.ListUsers(SDE_Workspace)&lt;/P&gt;&lt;P&gt;for user in userList:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;print ("Username: {0}, Connected at: {1}, ID: {2}, IsDirectConnection: {3}".format(user.Name, user.ConnectionTime, user.ID, user.IsDirectConnection))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# get a list of user names from the list of named tuples returned from ListUsers&lt;/EM&gt;&lt;BR /&gt;userNames = [u.Name for u in userList]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# take the userNames list and make email addresses by appending the appropriate suffix.&lt;/EM&gt;&lt;BR /&gt;emailList = [name + '@myorganization.com' for name in userNames]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EMAILSERVER = "myorganization.us"&lt;BR /&gt;FROM = "username@myorganization.com"&lt;/P&gt;&lt;P&gt;TO = emailList&lt;BR /&gt;SUBJECT = "Maintenance is about to be performed"&lt;BR /&gt;MSG = "Auto generated Message.\n\rServer maintenance will be performed in 15 minutes. Please log off."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Prepare actual message&lt;/EM&gt;&lt;BR /&gt;MESSAGE = """\&lt;BR /&gt;From: %s&lt;BR /&gt;To: %s&lt;BR /&gt;Subject: %s&lt;/P&gt;&lt;P&gt;%s&lt;BR /&gt;""" % (FROM, ", ".join(TO), SUBJECT, MSG)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;# Send the mail&lt;/EM&gt;&lt;BR /&gt;server = smtplib.SMTP(EMAILSERVER)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2019 18:16:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368629#M29046</guid>
      <dc:creator>Jen_Zumbado-Hannibal</dc:creator>
      <dc:date>2019-10-10T18:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Email list of connected users needs character stripping</title>
      <link>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368630#M29047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Jennifer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;emailList = [name[1:-1] + &lt;/SPAN&gt;&lt;A class="" href="mailto:'@myorganization.com"&gt;'@myorganization.com&lt;/A&gt;&lt;SPAN&gt;' for name in userNames]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The [1:-1] should strip the first and last characters in the username.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Josh&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2019 19:04:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368630#M29047</guid>
      <dc:creator>GeoJosh</dc:creator>
      <dc:date>2019-10-10T19:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Email list of connected users needs character stripping</title>
      <link>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368631#M29048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Thanks Joshua. That worked great! However, one more question...if I wanted to exclude a particular user name...say the user name that publishes REST services as an owner....would it be with an&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG style="border: 0px; font-weight: bold;"&gt;if...then&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statement or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG style="border: 0px; font-weight: bold;"&gt;if....else&lt;/STRONG&gt;? And where within my script would I write it? After the tuple or before? How would I go about doing it? These are the things that really get to me in a pickle.&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Thanks once again.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2019 21:46:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368631#M29048</guid>
      <dc:creator>Jen_Zumbado-Hannibal</dc:creator>
      <dc:date>2019-10-10T21:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Email list of connected users needs character stripping</title>
      <link>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368632#M29049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jennifer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could define a list of usernames you wish to &lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;exclude,&lt;/SPAN&gt; and do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;userNames = [u.Name for u in userList]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;exclusion_list = ["Josh", "Jennifer"]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;for name in userNames:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if name in exclusion_list:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; userNames.remove(name)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;&lt;SPAN&gt;emailList = [name + &lt;/SPAN&gt;&lt;A class="" href="mailto:'@myorganization.com"&gt;'@myorganization.com&lt;/A&gt;&lt;SPAN&gt;' for name in userNames]&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;-Josh&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Oct 2019 12:07:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368632#M29049</guid>
      <dc:creator>GeoJosh</dc:creator>
      <dc:date>2019-10-11T12:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Email list of connected users needs character stripping</title>
      <link>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368633#M29050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It worked great! Thanks so much.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Oct 2019 17:05:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/email-list-of-connected-users-needs-character/m-p/368633#M29050</guid>
      <dc:creator>Jen_Zumbado-Hannibal</dc:creator>
      <dc:date>2019-10-15T17:05:10Z</dc:date>
    </item>
  </channel>
</rss>

