SendMail
(VTScada-Layer function. Must be called with a leading backslash.)
Description: | Sends a string to an email server using the Simple Mail Transport Protocol (SMTP) |
Returns: | Nothing |
Usage: | Script Only. |
Function Groups: | |
Related to: | ValidateEmailAddrs |
Format: | \SendMail(Server, To, From, Subject, Message, Error [,Attachments, AttachmentStreams, OptionalHeaders, ErrorText, SenderMailbox, Username, Password, UseTLS, Bcc, Charset, Port, UseOauth2, OAuth2GrantID, EncryptedSettings, ContentType]) |
Parameters: |
Server | ||||||||||||||||||||||||||||||||
Required. Any text or buffer expression of the mail server name or IP address | ||||||||||||||||||||||||||||||||
To | ||||||||||||||||||||||||||||||||
Required. Any text or buffer expression of the address of destination | ||||||||||||||||||||||||||||||||
From | ||||||||||||||||||||||||||||||||
Required. Any text or buffer expression of the address of the person from whom the mail is from | ||||||||||||||||||||||||||||||||
Subject | ||||||||||||||||||||||||||||||||
Required. Any text or buffer expression of the subject of the message | ||||||||||||||||||||||||||||||||
Message | ||||||||||||||||||||||||||||||||
Required. Any text or buffer expression of the message - no attachments | ||||||||||||||||||||||||||||||||
Error | ||||||||||||||||||||||||||||||||
Required. A pointer to an error variable, set to 0 if OK. The Error parameter should initially be set Invalid by the caller. When this method is done, it will set Error to one of the following values: The following error codes are produced by VTScada. Your email server may produce others.
|
Attachments |
An optional parameter that is an array of file names to be attached to the email message. |
AttachmentStreams |
An optional parallel array of attachment streams. |
OptionalHeaders |
A string of optional MIME headers, separated by CRLF. |
ErrorText |
An optional pointer to the variable that holds the phrase key of the error message. Use \GetPhrase() to translate this ID to the language currently in use. |
SenderMailbox |
An optional parameter which is the SMTP reverse path. SenderMailbox overrides the From parameter. This parameter may be used as an alternative to the From parameter when specifying the "MAIL FROM" address in the SMTP. The From parameter would still be used when specifying the "From:" address in the email header. SenderMailbox should be used only when an email is intended to look like it came from a particular address, but has actually originated from another address. |
Username |
Allows a user name to be provided to email servers that require authentication. |
Password |
Allows a password to be provided to email servers that require authentication. |
UseTLS |
Boolean to indicate that transport layer security should be used. |
Bcc |
Optional list of recipients, who should receive a bcc copy of the message. |
Charset |
Optional. Text string to be used for MIME character set. |
Port |
Optional numeric. Use to specify which port the SMTP server should use. If not provided, the value of the SMTPPort application setting is used, defaulting to 25. |
UseOAuth2 |
Optional Boolean. Set TRUE use Auth |
OAuth2GrantID |
Text. Must be set if UseOAuth2 is TRUE. The Grant ID |
EncryptedSettings |
Optional text. A set of encrypted mail settings to use. |
ContentType |
Body content type (text/plain, text/html) |
Comments: |
This function opens a TCP/IP socked on port 25 (or other if specified) of the specified mail server. The Message is then sent using the SMTP protocol. The To: address will accept a string that conforms to the address-list ABNF from RFC 5322. If using OAuth2 and the server does not offer XOAUTH2 as an authentication method then error 10 is returned. |
Example:
\SendMail("192.168.0.201", "sales@trihedral.com", "vts@trihedral.com", "Great Product!", "VTScada is Great\n\rMust buy lots!", &ErrorCode);