ph_sendsmtpemailasync PowerHome formula function
Description
Sends email via SMTP asynchronously with the
option to automatically perform a PowerHome action once the email is
sent.
Syntax
ph_sendsmtpemailasync ( type, id, server,
port, from, to, subject, message
)
Argument |
Description |
type |
Integer. The type of PowerHome action you'd like executed
when the email is sent. Use 0 to not trigger any action. Use 1 to trigger
a macro. Use 2 to execute a named formula ID. Use 3 to execute a raw
formula. This parameter goes hand in hand with the id parameter. |
id |
String. Data for the triggered action. If type is 0, then
set this parameter to an empty string. If type is 1, then set ID to a
valid macro ID. If type is 2, then set ID to a valid formula ID. If type
is 3, then ID should contain a valid raw formula you'd like to be
executed. |
server |
String. The IP or URL of the SMTP server. |
port |
Long. The port for the SMTP server. Typically, this will be
25. |
from |
String. An email address for who the
mail is from. If your SMTP server requires authentication then this field
will also contain the userid and password. See usage below for more detail. |
to |
String. The email address to send the
email to. If you're sending to multiple recipients, then separate the
email addresses with a comma. |
subject |
String. The subject of the email. |
message
|
String. The message body of the
email.
|
Return value
Integer. This function will return
a 0.
Usage
Use this function to send email via SMTP
asynchronously. Email will be sent in the background and PowerHome will operate
without hanging for the email to complete. If you'd like to trigger an action
once the email is sent, set the type and id parameters appropriately.
If you trigger a process (type =
1, 2, 3) when the email is sent, then your macro
or formula will have access to the results of the SMTP email send operation.
Three return values are available. Use ph_getmtret to retrieve the results of
the send process. If successful, this value will be 0. If a failure occured,
this value will be a positive number from 1 to 9 indicating at what step in the
send process the failure occured. Use ph_getlasterror to retrieve a numeric
value indicating what the specific error was. This value will be 0 if there is
no failure, otherwise non-zero if a failure occured. Use ph_getlasterrorstring
to retrieve a string representation of what step in the send process a failure
occured. If email transmission was successful, then this string will indicate
success.
If your SMTP server requires authentication, then embed
the credentials in the from parameter. The from parameter should first contain
the from email address followed by a comma (don't use any spaces) followed by
the SMTP userid followed by a comma followed by the
SMTP password.
Examples
The following examples demonstrate typical syntax/usage for this function.
ph_sendsmtpemailasync(1,"EMAILCOMPLETE","www.smtpserver.com",25,"power-home.com,ph,mypass","dhoward@myx10.com","Test
Message","This is a test message body")
The above example will send email
asynchronously and when complete, will execute the EMAILCOMPLETE
macro.