Outlook Mail (Office 365) Connector
Documentation
Version: 3
Documentation

Table MyMessages


Parameters

Parameter Label Required Options Description Help
There are no parameters

Supported Operations

Below section contains supported CRUD operations. Each operation is executed by some EndPoint behind the scene.
Method Supported Reference EndPoint
SELECT get_my_messages
INSERT send_mail
UPDATE
UPSERT
DELETE
LOOKUP get_my_message

Examples

SSIS

Use Outlook Mail (Office 365) Connector in API Source component to read data or in API Destination component to read/write data:

Read from MyMessages table using API Source

Outlook Mail (Office 365)
MyMessages
SSIS API Source - Read from table or endpoint

Read/write to MyMessages table using API Destination

Outlook Mail (Office 365)
MyMessages
Select
SSIS API Destination - Access table operation

ODBC application

Use these SQL queries in your ODBC application data source:

Get messages for the current user

SELECT * FROM MyMessages

Get a specific message from the current user's account by the message ID

SELECT * FROM MyMessages
WHERE Id='AAXkADIwNzNhODMyLTZiMTQtNDhiMC02OWQzLTc5YTY5M2IyMjk0NABGAyAAAACbj2hVuNphT74wylrfU4ixBwAbUV6IxRnpQrqzrb2WfacdAAAAAAEMAAAbUV6IxRnpQrqzrb2WfacdAAAysBnxAAA='

Get messages for the current user ordered by the time they were sent in ascending order

SELECT * FROM MyMessages WITH (OrderBy='sentDateTime')

Get messages for the current user ordered by the time they were sent in descending order

SELECT * FROM MyMessages WITH (OrderBy='sentDateTime desc')

Get messages for the current user ordered by the time they were received in ascending order

SELECT * FROM MyMessages WITH (OrderBy='receivedDateTime')

Get messages for the current user ordered by the time they were received in descending order

SELECT * FROM MyMessages WITH (OrderBy='receivedDateTime desc')

Get messages for the current user ordered by the name of the sender in ascending order

SELECT * FROM MyMessages WITH (OrderBy='sender/emailAddress/name')

Get messages for the current user ordered by the name of the sender in descending order

SELECT * FROM MyMessages WITH (OrderBy='sender/emailAddress/name desc')

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

SQL Server

Use these SQL queries in SQL Server after you create a data source in Data Gateway:

Get messages for the current user

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];

Get a specific message from the current user's account by the message ID

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages
WHERE Id=''AAXkADIwNzNhODMyLTZiMTQtNDhiMC02OWQzLTc5YTY5M2IyMjk0NABGAyAAAACbj2hVuNphT74wylrfU4ixBwAbUV6IxRnpQrqzrb2WfacdAAAAAAEMAAAbUV6IxRnpQrqzrb2WfacdAAAysBnxAAA=''';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];

Get messages for the current user ordered by the time they were sent in ascending order

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages WITH (OrderBy=''sentDateTime'')';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];

Get messages for the current user ordered by the time they were sent in descending order

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages WITH (OrderBy=''sentDateTime desc'')';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];

Get messages for the current user ordered by the time they were received in ascending order

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages WITH (OrderBy=''receivedDateTime'')';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];

Get messages for the current user ordered by the time they were received in descending order

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages WITH (OrderBy=''receivedDateTime desc'')';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];

Get messages for the current user ordered by the name of the sender in ascending order

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages WITH (OrderBy=''sender/emailAddress/name'')';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];

Get messages for the current user ordered by the name of the sender in descending order

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM MyMessages WITH (OrderBy=''sender/emailAddress/name desc'')';

EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_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 [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];