EMAIL_SMTP_SEND Function
Syntax
Arguments
- pMessagePointer
A pointer variable containing the message with the following properties:
- fromCharacter
The sender's email address.
- from_aliasCharacter
The sender's name.
- toCharacter
The recipient list. Multiple entries are separated by commas. Microsoft Outlook allows you to format the address as "recipient_name". This hides the "" portion of the field from the recipient.
- ccCharacter
The CC list. Multiple entries are separated by commas.
- charsetCharacter
Specifies the character set you want to use, ex. UTF8. Defaults to us-ascii if not otherwise specified.
- bccCharacter
The BCC list. Multiple entries are separated by commas.
- subjectCharacter
The subject line of the email.
- messageCharacter
The body of a text message.
- html_messageCharacter
The body of a HTML message.
- attachmentsCharacter
A semi-colon (;), comma, or CR-LF delimited list of filenames.
- xmailerCharacter
Default = NULL. The sending email program.
- lRelatedLogical
Default = .F.. If .T. = Attachments are embedded image in the HTML message. If .F. = Attachments are separate files.
- ReturnReceiptLogical
Default = .F. (Requires V8, addin build 3090 or later). If .t. then an e-mail will be sent to the sender acknowledging that the recipient has read the e-mail. Note that not all e-mail clients support this feature and the recipient might decline to send the receipt.
- headersCharacter
Default = "". Optional email headers. Email headers are specified as a CR-LF delimited list of colon separated name-value pairs. Headers can be one of the standard mail headers or a user-defined header. Prefix user-defined headers with "X-".
dim headers as c =<<%str% Reply-To: [email protected] X-company: Example Co X-campaign: Spring Launch %str%
See RFC 822 to learn more about message headers.
The support of an email header is dependent on the email client. Some email clients may not support the header(s) you include in the message.
- pSocketPointer
A pointer variable that is populated by EMAIL_SMTP_OPEN().
- lStatusLogical
Default = .F. Whether to show a progress meter or not. .T. = Show a progress meter. .F. = Do not show a progress meter.
- autowrapLogical
Default = .T. Whether to force text emails to wrap at 72 characters per line. .T. = Automatically wrap all lines of text at 72 characters or less. .F. = Leave text email body unchanged.
Returns
- ResultLogical
Returns .T. if the message was sent successfully. Returns .F. if the message was not sent.
Description
The EMAIL_SMTP_SEND() function sends a message through a SMTP mail server. This function, along with EMAIL_SMTP_OPEN()and EMAIL_SMTP_CLOSE(), will allow you to send email from a computer that does not have an Alpha Anywhere email profile.
Example
DIM pm as P pm.from = "[email protected]" pm.from_alias = "Aaron Brown" pm.to = "[email protected]" pm.cc = "[email protected]" pm.bcc = "[email protected] pm.subject = "This is a test" pm.message = "This is the body of the message" pm.html_message = "HTML Body goes here pm.attachments = <<%str% C:\dev\test.zip C:\my documents\report.zip %str% 'optional header fields pm.xmailer = "Alpha Mailer" pm.lRelated = .F. 'optional email headers pm.headers = <<%txt% X-Company: Alpha Software X-Location: Boston X-CodeExample: Sending Email with Xbasic Reply-To: [email protected] %txt% ' send message dim ps as P if (email_smtp_open(ps, "mail.alphasoftware.com", 25, "username", "password")) THEN if (email_smtp_send(pm, ps)) then TRACE.writeLn("Email sent","Email Log") else TRACE.writeLn("Could not send email","Email Log") end if else TRACE.writeLn("Could not connect to SMTP server","Email Log") END IF email_smtp_close(ps)
Character Sets
You can specify the character set when using the email_smtp_send() function.
DIM pm as P pm.from = "[email protected]" pm.from_alias = "Aaron Brown" pm.to = "[email protected]" pm.subject = "This is a test" ' Text that contains non ascii characters - encoded as UTF8 pm.message = convert_acp_to_utf8("même manière") ' Indicate that we want to send the text with 'utf8' encoding pm.charset = "utf8" DIM ps as P if (email_smtp_open(ps, "mail.alphasoftware.com", 25, "username", "password")) then if (email_smtp_send(pm, ps)) then TRACE.writeLn("Email sent","Email Log") else TRACE.writeLn("Could not send email","Email Log") end if else TRACE.writeLn("Could not connect to SMTP server","Email Log") end if email_smtp_close(ps)
See Also