Coder Social home page Coder Social logo

patrykgruszka / attachment-downloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamesridgway/attachment-downloader

0.0 1.0 0.0 49 KB

Simple tool for downloading email attachments for all emails in a given folder using an IMAP client

License: MIT License

Python 100.00%

attachment-downloader's Introduction

Attachment Downloader

Build Status

Simple tool for downloading email attachments for all emails in a given folder using an IMAP client.

Install:

$ pip install attachment-downloader

Usage:

Usage: attachment-downloader [options]

Options:
  -h, --help            show this help message and exit
  --host=HOST           IMAP Host
  --username=USERNAME   IMAP Username
  --password=PASSWORD   IMAP Password
  --imap-folder=IMAP_FOLDER
                        IMAP Folder to extract attachments from
  --subject-regex=SUBJECT_REGEX
                        Regex that the subject must match against
  --date-after=DATE_AFTER
                        Select messages after this date
  --date-before=DATE_BEFORE
                        Select messages before this date
  --filename-template=FILENAME_TEMPLATE
                        Attachment filename (jinja2) template.
  --output=DOWNLOAD_FOLDER
                        Output directory for attachment download
  --delete              Delete downloaded emails from Mailbox
  --delete-copy-folder=DELETE_COPY_FOLDER
                        IMAP folder to copy emails to before deleting them
  --port=PORT           Specify imap server port (defaults to 993 for TLS and
                        143 otherwise
  --unsecure            disable encrypted connection (not recommended)
  --starttls            enable STARTTLS (not recommended)

Example:

$ attachment-downloader --host imap.example.com --username [email protected] --password pa55word \\
    --imap-folder invoices --output ~/Downloads

Messages from all folders

If you wish to search through all messages regardless of folder, omit the --imap-folder argument.

Date Filtering

Date filtering can be performed by specifying one or both of the date arguments:

--date-after="2021-02-06T13:00:00" --date-before="2021-02-06T13:25:00"

Dates should be provided in ISO format, e.g: 2021-02-06T13:25:00 or 2021-02-06T13:25:00.

If a zone offset is not provided UTC will be assumed.

Requirements

This tool requires Python 3+

This is not compatible with Python 2.

Filename Template

By default attachments will be downloaded using their original filename to the folder specified by -output.

You can customise the download filename using a jinja2 template for the argument --filename-template.

The following variables are supported:

  • message_id
  • attachment_name
  • attachment_idx
  • subject
  • date

In the following example, downloads will be placed within the output folder grouped into a folder hierarchy of date, message ID, subject:

--filename-template="{{date}}/{{ message_id }}/{{ subject }}/{{ attachment_name }}"

The datetime of the message can also be formatted in the output filename, for example:

--filename-template "{{date.strftime('%Y-%m-%d')}} {{ attachment_name }}"

Reporting Issues and Contributing

If you spot any issues or have a feature request please feel free to raise an issue, or even better, propose a pull request.

attachment-downloader's People

Contributors

jamesridgway avatar shawn-ogg avatar patrykgruszka avatar rschueler avatar jinnko avatar mtstevensw avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.