SendEmailMessage
Associated with: Users
Security permission required to access this method: Control
Use this method to send an email to a specified email address. The email address must be stored as a valid Email Contact in the user's configuration (see Define the E-Mail, Pager, and PIN Login Contact Settings for a User). You execute the method programmatically, for example, using a Python program.
Arguments:
-
EmailAddressNumber (Byte)—Specify the zero-based index of the email address that is stored in the user's configuration. The index is based on the order of Email Contacts that are listed on the Contact Information tab on the User form. For example, index '0' is E-Mail Contact 1, index '1' is E-Mail Contact 2, and so on.
-
Subject (String)—Specify the subject line of the email.
-
Message (String)—Add the contents of the email.
The sending process is asynchronous. This means that the method does not return a success code to indicate that the email has been successfully delivered.
The following Python program is used to send an email to the first email address that is stored in the configuration of user 'Gregory1':
from getpass import getpass
from geoscada.client import ConnectionManager
from geoscada.lib.variant import Variant, VariantType
username = input("Username: ")
password = getpass() if username != '' else ''
with ConnectionManager('localhost', 5481, 'SendEmailMessageExample') as connection:
if username != '':
connection.log_on(username, password)
user = connection.find_object("Gregory1")
connection.invoke_method(
user.id,
'SendEmailMessage',
[
Variant(VariantType.UI1, 0),
Variant(VariantType.BStr, "A Subject"),
Variant(VariantType.BStr, "A Message")
]
)