email_send_sparkpost Function
Syntax
Arguments
- keyCharacter
Your SparkPost API key. Leave blank (an empty string) to use the API key stored in [Web Project Properties].
- messageCharacter Pointer
Can be a JSON string that defines the message or object with message properties listed below. See examples for more info.
- use_EULogical
Set to .t. to use SparkPost's EU server. Defaults to .f., which uses the US server.
Returns
- ResultPointer
Returns an object that has the properties below that includes information about whether or not the message was delivered to the SparkPost server. The returned variable does not include information as to whether or not the message was delivered to each recipient. The return value also includes the JSON message definition that was constructed from the message object.
- errorLogical
.t. if an error occurs. Otherwise .f..
- errorTextCharacter
Information about why the email failed to send if error is .t..
- jsonCharacter
A JSON string containing the message that was generated.
- resultPointer
An object with the following properties:
- errorsCharacter
An array of error messages, if any are returned by the function call.
Description
Send an email using the SparkPost service.
Using email_send_sparkpost
This Xbasic helper function can be used to send email using the SparkPost service. You must first go to sparkpost.com to get an API key. You will also be required to verify ownership of your sending domain.
Once you have your API key and have verified your domain ownership, you can send email. If your SparkPost account is based in the European Union, set the use_EU parameter to .t. to use the EU server.
Example
dim ms as p ms.send_to = "[email protected]" ms.from_email = "[email protected]" ms.subject = "Greetings!" ms.message_text = "Hello there!" dim key as c = "" ' leave blank to use key stored in Web Project Properties dim use_EU as L = .f. ' Set to .t. to use the EU server dim result as p result = email_send_sparkpost(key, ms, use_EU)