I'd like to send an html email to all users with a specific role, similarly to how you'd email a report:
The scripting library doesn't seem to have a way to specify an Address Source
like this for the system.net.sendEmail
function. Is this function I made the cleanest way to get the email addresses I'm looking for from a Perspective scripting context?
def get_user_emails_with_role(user_source, role):
emails = []
for user in system.user.getUsers(user_source):
if role in user.roles:
for contact_info in user.contactInfo:
if contact_info.contactType == 'email':
emails.append(str(contact_info.value))
return emails