SendEmail
- Last UpdatedOct 29, 2026
- 2 minute read
SendEmail is a built-in function that sends an email message.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
SendEmail |
|
Synchronous |
No |
Supported |
Supported |
Not supported |
Supported (see "Notes") |
Executed on Server |
Syntax
SendEmail(strSubject,strMessage,strTo)
strSubject
The subject of the email.
strMessage
The message body of the email, up to 255 characters long.
strTo
The email address of the intended recipient.
Return value
|
Value |
Description |
|---|---|
|
0 |
Success |
|
1 |
Invalid format for strSubject |
|
2 |
Invalid format for strMessage |
|
3 |
Invalid format for strTo |
|
4 |
Wrong number of parameters |
|
5 |
Start socket error |
|
6 |
Error getting host IP Address (invalid SMTP server) |
|
7 |
Error connecting to SMTP server |
|
8 |
Error sending HELO command (initialization) |
|
9 |
Error sending MAIL command (the "From" address) |
|
10 |
Error sending RCPT command (the "To" address) |
|
11 |
Error sending DATA (the message body) |
|
12 |
Error sending SMTP authentication command |
|
13 |
Invalid username |
|
14 |
Invalid password |
|
15 |
Data Protection is enabled (see Notes below). |
Notes
In order to send email, configure the email settings with the CnfEmail function, or use the E-mail Settings tab of the E-Mail and FTP configuration dialog to configure your project's email settings. Incorrect settings can result in several different error codes (see above).
This function cannot be executed on thin clients (in the Viewer module) when Data Protection is enabled. It can only be executed on the project runtime server. For more information, see Enable Data Protection to encrypt sensitive information.
Also, SendEmail cannot be used when encryption via TLS/SSL is enabled, nor to send an email that contains Unicode characters. Use the SendEmailExt function instead.
Examples
SendEmail("Hi!","How are you?","rogers@pnd.net")
SendEmail(statusSummary,statusDetail,adminAddress)