Endpoint Download Message Attachments (With search condition)
Name
download_message_attachments
Description
Lists the message attachments for the specified search criterial and user id
Parameters
| Parameter | Required | Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Name:
Label: SaveFolder Specify a disk folder path to save file(s) to |
YES | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: OverwriteFile |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: Search Expression Expression to return messages matching the specified query. Supports the same query format as the Gmail search box. |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: IncludeSpamTrash Include messages from SPAM and TRASH in the results. |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: LabelIds Only return messages with labels that match all of the specified label IDs. Messages in a thread might have labels that other messages in the same thread don't have. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: MaxResults Maximum number of messages to return. This field defaults to 100. The maximum allowed value for this field is 500. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: ApiVersion The version of the API to use. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: UserId Enter the Gmail user ID. |
|
Output Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description |
|---|---|---|---|---|
| MessageId |
DT_WSTR
|
nvarchar(50)
|
50 | |
| PartId |
DT_WSTR
|
nvarchar(50)
|
50 | |
| AttachmentId |
DT_WSTR
|
nvarchar(1000)
|
1000 | |
| MimeType |
DT_WSTR
|
nvarchar(200)
|
200 | |
| Filename |
DT_WSTR
|
nvarchar(108)
|
108 | |
| Headers |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| AttachmentSize |
DT_I8
|
bigint
|
||
| PayloadMimeType |
DT_WSTR
|
nvarchar(200)
|
200 | |
| ThreadId |
DT_WSTR
|
nvarchar(50)
|
50 | |
| MessageSnippet |
DT_WSTR
|
nvarchar(1000)
|
1000 | |
| MessageSizeEstimate |
DT_I8
|
bigint
|
||
| InternalDate |
DT_WSTR
|
nvarchar(50)
|
50 | |
| HistoryId |
DT_WSTR
|
nvarchar(50)
|
50 | |
| Size |
DT_WSTR
|
nvarchar(50)
|
50 | |
| SavedPath |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| SavedSize |
DT_I8
|
bigint
|
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 Gmail Connector in API Source or in API Destination SSIS Data Flow components to read or write data.
API Source
| Required Parameters | |
|---|---|
| SaveFolder | Fill-in the parameter... |
| Optional Parameters | |
| OverwriteFile | True |
API Destination
| Required Parameters | |
|---|---|
| SaveFolder | Fill-in the parameter... |
| Optional Parameters | |
| OverwriteFile | True |
ODBC application
Use these SQL queries in your ODBC application data source:
Download Gmail message attchments to local disk
This example shows how to search messages using search condition and download all message attchments to local disk. File Path is {user_defined_folder} \ {message_id} + {atachment_file_name}
SELECT *
FROM download_message_attachments
--OR -- just read
--FROM get_message_attachments
WITH(
Search='subject:(daily report for July-2024)',
--Search='after:<<yearstart+1d|~|yyyy/MM/dd,FUN_TO_DATE>> before:<<today-1d|~|yyyy/MM/dd,FUN_TO_DATE>>'
SaveFolder='c:\temp',
OverwriteFile='True'
)
Download multiple attchments with search condition (sent after specific date)
This example shows how to download attachments for only those emails sent after specific date
SELECT *
FROM download_message_attachments
--OR -- just read
--FROM get_message_attachments
WITH(
Search='subject:(daily report for July-2024)',
--Search='has:attachment after:<<monthstart+1d|~|yyyy/MM/dd,FUN_TO_DATE>>'
SaveFolder='c:\temp',
OverwriteFile='True'
)
SQL Server
Use these SQL queries in SQL Server after you create a data source in Data Gateway:
Download Gmail message attchments to local disk
This example shows how to search messages using search condition and download all message attchments to local disk. File Path is {user_defined_folder} \ {message_id} + {atachment_file_name}
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT *
FROM download_message_attachments
--OR -- just read
--FROM get_message_attachments
WITH(
Search=''subject:(daily report for July-2024)'',
--Search=''after:<<yearstart+1d|~|yyyy/MM/dd,FUN_TO_DATE>> before:<<today-1d|~|yyyy/MM/dd,FUN_TO_DATE>>''
SaveFolder=''c:\temp'',
OverwriteFile=''True''
)';
EXEC (@MyQuery) AT [LS_TO_GMAIL_IN_GATEWAY];
Download multiple attchments with search condition (sent after specific date)
This example shows how to download attachments for only those emails sent after specific date
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT *
FROM download_message_attachments
--OR -- just read
--FROM get_message_attachments
WITH(
Search=''subject:(daily report for July-2024)'',
--Search=''has:attachment after:<<monthstart+1d|~|yyyy/MM/dd,FUN_TO_DATE>>''
SaveFolder=''c:\temp'',
OverwriteFile=''True''
)';
EXEC (@MyQuery) AT [LS_TO_GMAIL_IN_GATEWAY];