Using the Email Source Component
The Email Source Component is used to receive emails from a server and output them to columns. There are three pages of configuration:
- General
- Columns
- Error Handling
General Page
The General page of the Email Source component allows you to specify the general settings of the component.
- Connection Manager
-
The Email Source Component requires an Email connection. The Connection Manager drop-down will show a list of all Email connection managers that are available in your current SSIS package.
- Folder Path
-
the Folder Path determines which folder on the server emails will be retrieved from. This option cannot be used with the POP3 server because they do not support folders. For connections that use IMAP or Exchange Web Services, this option will default to 'Inbox'.
Clicking on the ellipsis button (...) will show a tree structure with the available folders.
- Show non-mail folders as well
-
This option, when selected, shows non-email folders (only available for EWS).
- Include Subfolders
-
Determines if subfolders below the root folder should be searched for email.
- Only Process Unread Messages
-
This option will determine if only messages that have not previously been read will be processed.
- Read Processed IDs from Variable
-
This option is only available with a POP3 server. Because POP3 messages do not support 'Read' flags, message IDs that the component has already processed must be loaded before processing.
- Mark Unread Messages as Read
-
This option will determine if messages should be marked as read after they are processed.
- Write Processed IDs to Variable
-
This option is only available with a POP3 server. Because POP3 messages do not support 'Read' flags, message IDs that the component has processed must be saved in a variable.
- Batch Size (since v2.0)
-
This Batch Size option is available for Exchange Web Services protocol connections to specify how many records you want to retrieve in each service call.
- Post Retrieve Action
-
This option will determine an action after the Emails have been retrieved. Available actions are:
- None
- Soft Delete
- Hard Delete
- Search Parameters
-
Search parameters can be entered that allow messages retrieved from the server to be filtered. Each parameter has a Field, Filter Type, and Value.
The field can be any column that has been selected on the columns page.
Filter type options depend on the field that has been selected. String fields support the 'Contains' and 'Does Not Contain' filter types. Numeric fields support the 'Greater Than', 'Less Than', and 'Equal To' filter types.
Columns Page
On the Columns page, you will see a list of all the output columns that are available and their types.
On the top left of the grid, there is a checkbox, which can be used to toggle the selection of all available fields. This is a productive way to check or uncheck all available fields.
The Columns Page grid consists of:
- Include Field Checkbox - A checkbox that determines if the field will be available as an output column.
- Field Name - Column that will be retrieved from Flat File.
- Data Type - The data type of this field.
- Filter
-
The output columns that are visible can be filtered by entering text in the Filter text box.
- Hide Unselected Fields
-
When the Hide Unselected Fields checkbox is checked unselected output columns will be hidden.
- Hide Used Fields
-
When the Hide Selected Fields checkbox is checked selected columns will be hidden.
- Add Button
-
Clicking on the Add button opens the 'Add Email Header' dialog and allows columns to be added that will map to headers in the email.
- Delete Button
-
The delete button will be enabled if a header column is selected. Clicking this button will delete the column.
The following email columns are available:
- Body: The body of the email.
- BodyHTML: The bodyHTML of the email.
- Cc: A list of email addresses that were Cc'd on the email.
- DateSent: The date the email was sent.
- From: The email address that the email was sent from.
- MessageID: The unique ID of the email message. This corresponds to the MessageID column in secondary output.
- Priority: The priority of the email.
- Size: The size of the email in bytes.
- Subject: The subject of the email.
- To: A list of the email addresses that were in the To field of this email.
Add Email Headers Dialog
If the Add button is clicked the Add Email Headers dialog will open. This will allow any email header to be mapped to a column. If the header appears multiple times in an email message all the values will be included in the output column as a JSON list.
- Column Name
-
A column name is automatically generated based on the header name that is entered.
- Header Name
-
The name of the email header.
- Data Type
-
Only the string data type is supported for email headers.
- Length
-
The length of the header column. Entering a length of 0 will create an ntext column with unlimited length.
Advanced Page
On the Advanced Page, you can configure advanced email settings.
- Choose two error-handling mechanisms:
- The Choose error-handling mechanism allows you to specify how errors should be handled when they happen. There are two options available:
- Fail on error: the component will fail when an error happens.
- Log error and attempt to continue execution: when this option is selected, failure records will be logged in the package's Execution Result and the execution will continue.
- Fail on error: the component will fail when an error happens.
Outputs
The Email component supports three outputs:
Primary Output: Primary output will consist of the columns available on the columns page.
Attachment Output: Attachment output is used to output any attachments that are associated with the messages in the primary input. It has three columns:
- MessageID: This corresponds to the MessageID of the message the attachments are associated with.
- FileName: This column contains the name of the attachment file.
- AttachmentContent: This column contains the content of the attachment file as a DT_IMAGE.
Resource Output(since v21.2): Resource output is used to output image data that are in the email body. It has three columns:
- MessageID: This corresponds to the MessageID of the message the attachments are associated with.
- FileName: This column contains the name of the attachment file.
- ResourceContent: This column contains the content of the image file as a DT_IMAGE.