SendMail
Sends a mail.
プロシージャ固有の情報
DynamicTemplateData インプットはテンプレートの動的データに関する情報を必要とします。テンプレートに入れる各種変数の値。
例:{"fullname":"Test","paymenttotal":"Test","description":"Test"}
NOTE:TemplateId カラムは、Dynamics Templates を使用する場合に必須です。
SendMail ストアドプロシージャにPersanalizations オブジェクトを追加する処理
SendMail では、リクエストボディに少なくとも1つのpersonalizations オブジェクトが必要で、集計関数を使用して追加できます。
例:
TEMP テーブルを使用。
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'
Aggregate 値を使用。
単一のメールアドレスにメールを送信。
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" }'
複数のメールアドレスにメールを送信。
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. |