Endpoint Send Mail
Name
send_mail
Description
Sends an email message. [API reference]
Related Tables
Parameters
| Parameter | Required | Options |
|---|---|---|
|
Name:
Label: User ID or Email The Microsoft Mail user ID GUID or email address for the account to read messages from. (Examples: '4ff54a77-9c09-4274-958f-83bdc0a53900' or 'first.last@domain.com'). To populate this drop down (GET /users), User Credentials need User.ReadBasic.All delegated scope (in the default list; regenerate token after adding). Add User.Read.All only if you need full user profiles. Application Credentials need User.Read.All application permission with admin consent in Azure Portal. You can also type a user id or email manually if listing fails. |
YES |
Output Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description |
|---|---|---|---|---|
| Id |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| Response |
DT_WSTR
|
nvarchar(255)
|
255 |
Input Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description |
|---|---|---|---|---|
| Subject |
DT_WSTR
|
nvarchar(250)
|
250 | |
| BodyContentType |
DT_WSTR
|
nvarchar(8)
|
8 | |
| BodyContent |
DT_NTEXT
|
nvarchar(MAX)
|
||
| ToRecipients |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| CcRecipients |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| BccRecipients |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| InternetMessageHeaders |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| Attachments |
DT_NTEXT
|
nvarchar(MAX)
|
||
| Importance |
DT_WSTR
|
nvarchar(10)
|
10 | |
| IsDeliveryReceiptRequested |
DT_BOOL
|
bit
|
||
| IsReadReceiptRequested |
DT_BOOL
|
bit
|
||
| SaveToSentItems |
DT_BOOL
|
bit
|
Examples
SSIS
Use Outlook Mail (Office 365) Connector in API Source or in API Destination SSIS Data Flow components to read or write data.
API Destination
This Endpoint belongs to the MyMessages table, therefore it is better to use it, instead of accessing the endpoint directly. Use this table and table-operation pair to send mail:
| Required Parameters | |
|---|---|
| User ID or Email | Fill-in the parameter... |
| Optional Parameters | |
| DoNotOutputEmptyNestedProperty | True |
| DoNotOutputEmptyArrayProperty | True |
| RawOutputDataRowTemplate | {} |
| EnableRawOutputModeSingleRow | True |
ODBC application
Use these SQL queries in your ODBC application data source:
Send an email
<p>Sends an email via the Office 365 API. You can set headers, HTML or text body, recipients, and attach local files. Use <code>BodyContentType</code> set to <code>Text</code> for plain text instead of HTML.</p>
INSERT INTO MyMessages
(Subject, BodyContentType, BodyContent
, ToRecipients, CcRecipients, BccRecipients
, InternetMessageHeaders
, Attachments, Importance, IsDeliveryReceiptRequested, IsReadReceiptRequested
, SaveToSentItems)
VALUES
('Employee Reviews Scheduled', 'HTML', '<b>Hi All,</b> employee reviews have been scheduled. <span style="text-decoration: underline;">Please reflect this in your notes.</span>',
'[{ "emailAddress": { "address": "john.doe@domain.com" }}, { "emailAddress": { "address": "jane.doe@domain.com" }}]',
'[{ "emailAddress": { "address": "mary.dawson@domain.com" }}]',
'[{ "emailAddress": { "address": "ryan.connor@domain.com" }}]',
'[{ "name": "x-custom-header-group-name", "value": "Managers" }, { "name": "x-custom-header-group-id", "value":"MGR001" }]',
'[
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "file1.txt",
"contentType": "text/plain",
"contentBytes": "<<c:\file1.txt,FUN_FILE_BASE64ENC>>"
},
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "profile-picture.png",
"contentType": "image/png",
"contentBytes": "<<c:\profile-picture.png,FUN_FILE_BASE64ENC>>"
}
]',
'normal', 'false', 'false', 'true')
send_mail endpoint belongs to
MyMessages
table(s), and can therefore be used via those table(s).
SQL Server
Use these SQL queries in SQL Server after you create a data source in Data Gateway:
Send an email
<p>Sends an email via the Office 365 API. You can set headers, HTML or text body, recipients, and attach local files. Use <code>BodyContentType</code> set to <code>Text</code> for plain text instead of HTML.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'INSERT INTO MyMessages
(Subject, BodyContentType, BodyContent
, ToRecipients, CcRecipients, BccRecipients
, InternetMessageHeaders
, Attachments, Importance, IsDeliveryReceiptRequested, IsReadReceiptRequested
, SaveToSentItems)
VALUES
(''Employee Reviews Scheduled'', ''HTML'', ''<b>Hi All,</b> employee reviews have been scheduled. <span style="text-decoration: underline;">Please reflect this in your notes.</span>'',
''[{ "emailAddress": { "address": "john.doe@domain.com" }}, { "emailAddress": { "address": "jane.doe@domain.com" }}]'',
''[{ "emailAddress": { "address": "mary.dawson@domain.com" }}]'',
''[{ "emailAddress": { "address": "ryan.connor@domain.com" }}]'',
''[{ "name": "x-custom-header-group-name", "value": "Managers" }, { "name": "x-custom-header-group-id", "value":"MGR001" }]'',
''[
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "file1.txt",
"contentType": "text/plain",
"contentBytes": "<<c:\file1.txt,FUN_FILE_BASE64ENC>>"
},
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "profile-picture.png",
"contentType": "image/png",
"contentBytes": "<<c:\profile-picture.png,FUN_FILE_BASE64ENC>>"
}
]'',
''normal'', ''false'', ''false'', ''true'')';
EXEC (@MyQuery) AT [LS_TO_OUTLOOK_MAIL_OFFICE_365_IN_GATEWAY];
send_mail endpoint belongs to
MyMessages
table(s), and can therefore be used via those table(s).