Reference

Endpoint Send Mail


Name

send_mail

Description

Sends an email message. [API reference]

Related Tables

MyMessages

Parameters

Parameter Required Options
Name: UserId

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')
YES

Output Columns

Label Data Type (SSIS) Data Type (SQL) Length Description
Id DT_WSTR nvarchar(4000) 4000
Response DT_WSTR nvarchar(255) 255
If the column you are looking for is missing, consider customizing Outlook Mail (Office 365) Connector.

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
Required columns that you need to supply are bolded.

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:

API Destination - Outlook Mail (Office 365)
Outlook Mail Connector (Office 365) can be used to integrate Office 365 Outlook Mail API in your App / BI Tools. You can download attachment, read / search Emails, Users, MailFolders, Send email and more.
Outlook Mail (Office 365)
MyMessages
Insert
Required Parameters
User ID or Email Fill-in the parameter...
Optional Parameters
DoNotOutputEmptyNestedProperty True
DoNotOutputEmptyArrayProperty True
RawOutputDataRowTemplate {}
EnableRawOutputModeSingleRow True
SSIS API Destination - Access table operation

ODBC application

Use these SQL queries in your ODBC application data source:

Send a simple email message (with headers, HTML body, recipients, attachments and more)

This example shows how to send email using Office 365 API. It shows how to attach local file(s) as attachments. To send email as Text format use Text rather than HTML in BodyContentType value.

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 a simple email message (with headers, HTML body, recipients, attachments and more)

This example shows how to send email using Office 365 API. It shows how to attach local file(s) as attachments. To send email as Text format use Text rather than HTML in BodyContentType value.

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).