EndPoint Download Message Attachments (Multiple Files) - Using Search Condition
Name
download_message_attachments
Description
Downloads multiple attachments for a specified search condition to select Mails
Parameters
Parameter | Label | Required | Options | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
UserId | User ID or Email | YES | 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') | |||||||||||||||||||||||||||||||||||||||||||||||||||
SaveFolder | SaveFolder | YES | Specify a disk folder path to save file(s) to | |||||||||||||||||||||||||||||||||||||||||||||||||||
EmailBodyFormat | Email Body Format | YES |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
MailFolderId | MailFolderId | NO | ||||||||||||||||||||||||||||||||||||||||||||||||||||
OverwriteFile | OverwriteFile | NO |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
SearchCriteria | Search Criteria | NO |
|
Data filter (e.g. somecolumn -eq 'somevalue'), you can use Date time functions for dynamic date. You can use keywords like now,today,yesterday,monthstart,monthend,yearstart,yearend,weekstart,weekend along with operator + / - [hour,minute,second,day,month,year] [API reference] | ||||||||||||||||||||||||||||||||||||||||||||||||||
OrderBy | Order By | NO |
|
Order the specified column by ascending or descending order [API reference] | ||||||||||||||||||||||||||||||||||||||||||||||||||
PageSize | Page Size | NO | The number of records to include in each page of results [API reference] |
Output Columns
Label | Data Type (SSIS) | Data Type (SQL) | Length | Raw | Description |
---|---|---|---|---|---|
Id |
DT_STR
|
varchar(255)
|
255 | False |
|
MessageId |
DT_STR
|
varchar(255)
|
255 | False |
|
Name |
DT_WSTR
|
nvarchar(500)
|
500 | False |
|
ContentId |
DT_STR
|
varchar(255)
|
255 | False |
|
ContentType |
DT_STR
|
varchar(255)
|
255 | False |
|
ContentLocation |
DT_STR
|
varchar(1000)
|
1000 | False |
|
IsInLine |
DT_BOOL
|
bit
|
False |
||
LastModifiedDateTime |
DT_DBTIMESTAMP
|
datetime
|
False |
||
Size |
DT_I4
|
int
|
False |
||
SavedPath |
DT_WSTR
|
nvarchar(4000)
|
4000 | False |
|
SavedSize |
DT_I8
|
bigint
|
False |
Input Columns
Label | Data Type (SSIS) | Data Type (SQL) | Length | Raw | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime. |
Examples
SSIS
Use Outlook Mail (Office 365) Connector in API Source component to read data or in API Destination component to read/write data:
Download Message Attachments (Multiple Files) - Using Search Condition using API Source

Download Message Attachments (Multiple Files) - Using Search Condition using API Destination

ODBC application
Use these SQL queries in your ODBC application data source:
Download multiple attchments with search condition
This example shows how to download Office 365 Email attachments with search criteria. In this example we used multiple conditions to search. For example search mail with attachments only, sent after 2023-03-01, subject contains string 'invoice' and email sent from microsoft-noreply@microsoft.com
SELECT * FROM download_message_attachments
WITH(
SaveFolder='c:\download',
OverwriteFile='True',
MailFolderId='INBOX', --or use mailbox ID
UserId='me', --or use "user-id" or use "email"
--search mail with attachments, sent after 2023-03-01, subject contains string "invoice" and from email is microsoft-noreply@microsoft.com
SearchCriteria='hasAttachments eq true and sentDateTime gt 2023-03-01 and contains(subject, ''invoice'') and from/emailAddress/address eq ''microsoft-noreply@microsoft.com'' ',
EmailBodyFormat='HTML' --or text
)
SQL Server
Use these SQL queries in SQL Server after you create a data source in Data Gateway:
Download multiple attchments with search condition
This example shows how to download Office 365 Email attachments with search criteria. In this example we used multiple conditions to search. For example search mail with attachments only, sent after 2023-03-01, subject contains string 'invoice' and email sent from microsoft-noreply@microsoft.com
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM download_message_attachments
WITH(
SaveFolder=''c:\download'',
OverwriteFile=''True'',
MailFolderId=''INBOX'', --or use mailbox ID
UserId=''me'', --or use "user-id" or use "email"
--search mail with attachments, sent after 2023-03-01, subject contains string "invoice" and from email is microsoft-noreply@microsoft.com
SearchCriteria=''hasAttachments eq true and sentDateTime gt 2023-03-01 and contains(subject, ''''invoice'''') and from/emailAddress/address eq ''''microsoft-noreply@microsoft.com'''' '',
EmailBodyFormat=''HTML'' --or text
)';
EXEC (@MyQuery) AT [LINKED_SERVER_TO_OUTLOOK_MAIL_OFFICE_365_IN_DATA_GATEWAY];