sendMail()
The sendMail() function sends encrypted e-mails using an SMTP
server.
Synopsis
void sendMail(string smtp_host, anytype email, int &ret,
string smtp_user = "", string smtp_pass = "", bool useTLS = FALSE, string
sAttachPath = "", bool verbose = false)
Parameters
| Parameter | Description |
|---|---|
| smtp_host | The name or address of the SMTP server. |
| email (dyn_string) |
The
|
| email (mapping) |
The
Optional keys:
|
| ret | Variable to store error codes that occur when sending or receiving e-mails, such as failed delivery or a full mailbox. |
| smtp_user | User name for the SMTP server. |
| smtp_pass | Password for the SMTP server. |
| useTLS | Set to TRUE to enable encryption and authentication (SSL/TLS). |
| sAttachPath | Full path to the attachment file(s). |
| verbose | Enables verbose output and can be used to receive additional details. |
Return value
This function does not return a value.
Errors
Possible errors include failure to send the e-mail, a full mailbox, or inability to connect to the SMTP server.
Details
To use sendMail(), you must add a reference to the
communication library:
#uses "communication"
This example sends an e-mail with the subject "Hello" and the body
"Hi this is a Test" to
maxMustermann@googlemail.com.
#uses "std.ctl"
#uses "communication"
main()
{
string smtp_host = "smtp.gmail.com:587";
dyn_string email;
email = makeDynString ("maxMustermann@googlemail.com", "maxMustermann@etm.at", "Test Mail","Hi, this is a Test and a copy of the mail will also be sent to Marie!", "marie.musterfrau@gmail.com");
int ret;
string smtp_user = "maxMustermann@googlemail.com";
string smtp_pass = "myPassword";
bool useTLS = TRUE;
string sAttachPath = "D:\\Downloads\\Image1.png";
sendMail(smtp_host, email, ret, smtp_user, smtp_pass, useTLS, sAttachPath);
}
Assignment
Availability
UI, CTRL
