Xbasic

send_email_using_ProjectPropertySettings Function

Syntax

C send_email_using_ProjectPropertySettings(p ms [,C send_to, C from_email, C from_name, C subject, C message_html, C message_text, C attachments, C cc, C bcc])

Arguments

msPointer

Pointer to an object containing email settings and message details.

send_toCharacter

Recipient email addresses (comma-separated list).

from_emailCharacter

Sender's email address.

from_nameCharacter

Sender's name (optional, friendly name).

subjectCharacter

Email subject line.

message_htmlCharacter

Email message in HTML format.

message_textCharacter

Plain text version of the email message.

attachmentsCharacter

Attachments to include with the email.

ccCharacter

CC recipients (comma-separated list).

bccCharacter

BCC recipients (comma-separated list).

Returns

resultCharacter

Returns a message indicating whether the email was successfully sent or an error message if it failed.

Description

When you send email in Alpha Anywhere, you can either use credentials that are stored in Project Properties (Email Settings) or explicitly define the email properties (such as the SMTP server, etc). The send_email_using_ProjectPropertySettings() function will send an email using the settings defined in Project Properties. The settings indicate whether the email should be sent using a specified server (Internal method) or a service (such as SparkPost or SendGrid).

Discussion

The send_email_using_ProjectPropertySettings() function allows sending emails from the server using the email settings defined in Project Properties.

Example usage:

dim ms as p
ms.send_to = "[email protected], [email protected]"
ms.from_email = "[email protected]"
ms.from_name = "Company Support"
ms.subject = "Account Update"
ms.message_html = "<b>Your account has been updated.</b>"
ms.message_text = "Your account has been updated."

dim result as c
result = send_email_using_ProjectPropertySettings(ms)
showvar(result)

If using placeholders in the message, ensure the e object is passed:

function xbCallback1 as c (e as p)
    dim ms as p
    ms.send_to = "{dialog.object}.getValue('email');"
    ms.from_email = "[email protected]"
    ms.subject = "Confirmation"
    ms.message_html = "<p>Thank you!</p>"
    
    send_email_using_ProjectPropertySettings(ms, e)
    
    return "{dialog.object}.setValue('status', 'Email sent!');"
end function

This function is used in conjunction with the Ajax Callback Action JavaScript with "Chunked Responses" enabled.

See Also