Xbasic

email_send_web Function

Syntax

dim result as P = email_send_web(C from ,C from_alias ,C to ,C cc ,C bcc ,C subject ,C message [,C attachments])

Arguments

fromCharacter

The sender's e-mail address.

from_aliasCharacter

The friendly/display name of the sender.

toCharacter

A comma delimited list of email addresses.

ccCharacter

A comma delimited list of email addresses to "CC".

bccCharacter

A comma delimited list of email addresses to "BCC".

subjectCharacter

The email subject.

messageCharacter

The message to send. Can contain HTML.

attachmentsCharacter

A comma delimited list of files to attach to the email.

Returns

resultPointer

Returns an object with the following properties:

errorLogical

A .t. or .f. value. If .t., an error occurred. Additional error information will be available in the errorText property. If .f., the email was successfully sent.

errorTextCharacter

A message containing additional information about why the email failed to send. This property only exists if error is .t..

Description

Sends an email using either the internal SMTP server or SparkPost using the settings defined in Web Project Properties.

Discussion

The email_send_web() function sends an email using settings defined in the Web Project Properties. The email will be sent using either the internal SMTP server or the SparkPost REST service.

Example:

dim from as C = "[email protected]"
dim from_alias as C = "Jane Smith"
dim to as C = "[email protected]"
dim cc as C = ""
dim bcc as C = ""
dim subject as C = "Thank you for registering!"
dim message as C = "We look forward to seeing you at next week's event."
dim attachments as C = ""

result = email_send_web(from, from_alias, to, cc, bcc, subject, message, attachments)

if (result.error == .f.) then
    ' Success!
else
    ' Something went wrong...
    dim errorMessage as C = result.errorText

    showvar(errorMessage)

end if