Reference

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 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
Name: SaveFolder

Label: SaveFolder

Specify a disk folder path to save file(s) to
YES
Name: EmailBodyFormat

Label: Email Body Format

YES
Option Value
html html
text text
Name: MailFolderId

Label: MailFolderId

Name: OverwriteFile

Label: OverwriteFile

Option Value
True True
False False
Name: SearchCriteria

Label: Search Criteria

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]
Option Value
None
From specific email 'from/emailAddress/address eq 'microsoft-noreply@microsoft.com'
Has Attachments hasAttachments eq true
Has Attachments, Sent After, and Subject containing 'party' hasAttachments eq true and sentDateTime gt 2023-03-01 and contains(subject, 'party')
Received before receivedDateTime lt 2023-02-01
Sent after sentDateTime gt 2023-03-01
Sent after (dynamic) sentDateTime gt <>
Search by Internet MessageId contains(internetMessageId,''59e62584-e364-453a-8444-5591a324ddaa@az.centralus.production.microsoft.com'') Has attachment(s)=hasAttachments eq true
Subject contains 'case' contains(subject, 'case')
Subject starts with 'Your' startsWith(subject, 'Your')
Subject does not start with 'Your' not(startsWith(subject, 'Your'))
Only normal importance importance eq 'normal'
Only low importance importance eq 'low'
Only high importance importance eq 'high'
Only if delivery receipt requested isDeliveryReceiptRequested eq true
Only if delivery receipt not requested isDeliveryReceiptRequested eq false
Only if read receipt requested isReadReceiptRequested eq true
Only if read receipt not requested isReadReceiptRequested eq false
Only if message is read isRead eq true
Only if message is unread isRead eq false
Only if message is a draft isDraft eq true
Only if message is not a draft isDraft eq false
Body content contains contains(body/content, 'money')
From Sender 'John Doe' sender/emailAddress/name eq 'John Doe'
Name: OrderBy

Label: Order By

Order the specified column by ascending or descending order
Option Value
None
AscendingOrder SomeColumn asc
DescendingOrder SomeColumn desc
Name: PageSize

Label: Page Size

The number of records to include in each page of results

Output Columns

Label Data Type (SSIS) Data Type (SQL) Length Description
Id DT_STR varchar(255) 255
MessageId DT_STR varchar(255) 255
Name DT_WSTR nvarchar(500) 500
ContentId DT_STR varchar(255) 255
ContentType DT_STR varchar(255) 255
ContentLocation DT_STR varchar(1000) 1000
IsInLine DT_BOOL bit
LastModifiedDateTime DT_DBTIMESTAMP datetime
Size DT_I4 int
SavedPath DT_WSTR nvarchar(4000) 4000
SavedSize DT_I8 bigint
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
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 or in API Destination SSIS Data Flow components to read or write data.

API Source

API Source - 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)
Download Message Attachments (Multiple Files) - Using Search Condition
Required Parameters
User ID or Email Fill-in the parameter...
SaveFolder Fill-in the parameter...
Optional Parameters
MailFolderId
OverwriteFile True
SSIS API Source - Read from table or endpoint

API Destination

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)
Download Message Attachments (Multiple Files) - Using Search Condition
Required Parameters
User ID or Email Fill-in the parameter...
SaveFolder Fill-in the parameter...
Optional Parameters
MailFolderId
OverwriteFile True
SSIS API Destination - Access table or endpoint

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 [LS_TO_OUTLOOK_MAIL_OFFICE_365_IN_GATEWAY];