Downloadfromimap¶
flowtask.components.DownloadFromIMAP
¶
DownloadFromIMAP
¶
Bases: IMAPClient, DownloadFromBase
DownloadFromIMAP.
Overview
Download emails from an IMAP mailbox using the functionality from DownloadFrom.
.. table:: Properties
:widths: auto
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| Name | Required | Summary |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| credentials | Yes | Credentials to access the IMAP mailbox. |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| mailbox | Yes | The IMAP mailbox name (default: "INBOX"). |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| search_terms | Yes | Dictionary containing search criteria in IMAP format. |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| attachments | Yes | Dictionary specifying download configuration for attachments: |
| | | - directory (str): Path to save downloaded attachments. |
| | | - filename (str, optional): Filename pattern for selection (fnmatch). |
| | | - pattern (str, optional): Regular expression pattern for selection. |
| | | - expected_mime (str, optional): Expected MIME type filter. |
| | | - rename (str, optional): Template string for renaming attachments (uses "{filename}"). |
| | | - download_existing (bool, optional): Skip existing files (default: True). |
| | | - create_destination (bool, optional): Create download directory if it doesn't exist (default: True). |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| download_existing | no | Flag indicating whether to skip downloading existing files. |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| results | Yes | Dictionary containing download results: |
| | | - attachments: List of downloaded attachment file paths. |
| | | - messages: List of `MailMessage` objects representing downloaded emails. |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
| use_ssl | Yes | Boolean for indicate if we need to use the TLS protocol |
+-------------------+----------+-----------+---------------------------------------------------------------------------------------------+
Save the downloaded files on the new destination.
Example:
```yaml
DownloadFromIMAP:
credentials:
host: email_host
port: email_port
user: email_host_user
password: email_host_password
use_ssl: true
search_terms:
'ON': '{search_today}'
SUBJECT: Custom Punch with Pay Codes - Excel
FROM: eet_application@adp.com
overwrite: true
attachments:
directory: /home/ubuntu/symbits/bose/files/worked_hours/
masks:
'{search_today}':
- today
- mask: '%d-%b-%Y'
```