SendMail
Sends a mail.
Procedure-Specific Information
The DynamicTemplateData input requires information about dynamic data of the template. Value for the different variables put into templates.
Example: {"fullname":"Test","paymenttotal":"Test","description":"Test"}
NOTE: The TemplateId column is required when using Dynamic Templates.
Process of adding Persanalizations object to SendMail Stored Procedure
SendMail Requires atleast one personalizations object in the request body and it can be added using the aggregate function.
For Example:
Using TEMP Tables.
INSERT INTO To#TEMP (ToEmail, ToName) VALUES ('[email protected]', 'abc') INSERT INTO To#TEMP (ToEmail, ToName) VALUES ('[email protected]', 'xyz') INSERT INTO To#TEMP (ToEmail) VALUES ('[email protected]') INSERT INTO ToCC#TEMP (ToCCName, ToCCEmail) VALUES ('[email protected]', 'xyz') INSERT INTO ToBCC#TEMP (ToBCCEmail, ToBCCName) VALUES ('[email protected]', 'abc') INSERT INTO Content#TEMP (ContentValue, ContentType) VALUES ('[email protected]', 'text/plain') INSERT INTO Personalizations#TEMP (FromEmail, SendAt, FromName, Subject, To, ToCC, ToBCC) VALUES ('[email protected]', '2017-10-30T10:57:00+01:00', 'hi', 'Test Subject2', 'To#TEMP', 'ToCC#TEMP', 'ToBCC#TEMP') EXEC SendMail Personalizations = 'Personalizations#TEMP', FromEmail = '[email protected]', Subject = 'hello', Content = 'Content#TEMP'
Using Aggregate values.
Send Mail to single Mail Address.
INSERT INTO Personalizations#TEMP (FromEmail, SendAt, FromName, Subject, To, ToCC, ToBCC) VALUES ('[email protected]', '2017-10-30T10:57:00+01:00', 'hi', 'Test Subject2', '[ { "ToEmail": "[email protected]", "ToName": "abc" } ]', '[ { "ToCCName": "xyz", "ToCCEmail": "[email protected]" } ]', '[ { "ToBCCEmail": "[email protected]", "ToBCCName": "abcd" } ]') EXEC SendMail Personalizations = 'Personalizations#TEMP', FromEmail = '[email protected]', Subject = 'hello', Content = '{ "ContentValue":"content", "ContentType":"text/plain" }'
Send Mail to Multiple Mail Addresses.
INSERT INTO Personalizations#TEMP (FromEmail, SendAt, FromName, Subject, To, ToCC, ToBCC) VALUES ('[email protected]', '2017-10-30T10:57:00+01:00', 'hi', 'Test Subject2', '[ { "ToEmail": "[email protected]", "ToName": "abc" }, { "ToEmail": "[email protected]", "ToName": "xyz" }, { "ToEmail": "[email protected]" } ]', '[ { "ToCCName": "sac", "ToCCEmail": "[email protected]" } ]', '[ { "ToBCCEmail": "xyz", "ToBCCName": "[email protected]" } ]') EXEC SendMail Personalizations = 'Personalizations#TEMP', FromEmail = '[email protected]', Subject = 'hello', Content = '{ "ContentValue":"content", "ContentType":"text/html" }'
Send Mail using attachment.
INSERT INTO To#TEMP (ToEmail, ToName) VALUES ('[email protected]', 'abc') INSERT INTO To#TEMP (ToEmail, ToName) VALUES ('[email protected]', 'xyz') INSERT INTO To#TEMP (ToEmail) VALUES ('[email protected]') INSERT INTO ToCC#TEMP (ToCCName, ToCCEmail) VALUES ('[email protected]', 'xyz') INSERT INTO ToBCC#TEMP (ToBCCEmail, ToBCCName) VALUES ('[email protected]', 'abc') INSERT INTO Content#TEMP (ContentValue, ContentType) VALUES ('[email protected]', 'text/plain') INSERT INTO Attachments#TEMP (AttachmentContent, AttachmentFilename) VALUES ('abcdefghijklmn', 'Test2.png') INSERT INTO Personalizations#TEMP (FromEmail, SendAt, FromName, Subject, To, ToCC, ToBCC) VALUES ('[email protected]', '2017-10-30T10:57:00+01:00', 'hi', 'Test Subject2', 'To#TEMP', 'ToCC#TEMP', 'ToBCC#TEMP') EXEC SendMail Personalizations = 'Personalizations#TEMP', FromEmail = '[email protected]', Subject = 'hello', Content = 'Content#TEMP', Attachments = 'Attachments#TEMP'
Input
Name | Type | Required | Description |
Subject | String | True | The subject of the mail to be sent. |
ContentValue | String | False | The content of the mail to be sent. |
ContentType | String | False | The type of content to be sent. supported values are text/plain and text/html |
Content | String | True | The aggregate for Content object |
SendAt | String | False | The date and time when you want your email to be delivered. Scheduling more than 72 hours in advance is forbidden. |
FromEmail | String | True | The email address of the sender. |
FromName | String | False | The name of the sender. |
ToEmail | String | False | Email address to send the mail to |
ToName | String | False | Email's respective names to send the mail to. |
To | String | False | The aggregate for To recipients |
ToCCEmail | String | False | Email address of the recipients who will receive a copy of your email |
ToCCName | String | False | Name of the recipients who will receive a copy of your email. |
ToCC | String | False | The aggregate for ToCC recipients. |
ToBCCEmail | String | False | Email address of the recipients who will receive a blind carbon copy of your email. |
ToBCCName | String | False | Name of the recipients who will receive a blind carbon copy of your email. |
ToBCC | String | False | The aggregate for ToBCC recipients. |
ReplyToEmail | String | False | The email address of the person to whom you are replying to. |
ReplyToName | String | False | The name of the person to whom you are replying to. |
AttachmentPaths | String | False | Path of the file to attach to the mail to be sent |
TemplateId | String | False | The Id of the template that you may want to send |
DynamicTemplateData | String | False | The data of the dynamic template. |
Personalizations | String | True | An array of messages and their metadata. Each object within personalizations can be thought of as an envelope - it defines who should receive an individual message and how that message should be handled. |
AttachmentFilename | String | False | The attachment's filename. Specify only when you don't specify the AttachmentPaths. |
Attachments | String | False | An array of objects where you can specify any attachments you want to include. Specify only when you don't specify the AttachmentPaths. |
Result Set Columns
Name | Type | Description |
Success | String | Whether or not the mail was sent successfully. |