Software engineer and technology nerd.
Here are some of my recent blog posts:
Simple tool for downloading email attachments for all emails in a given folder using an IMAP client
License: MIT License
Software engineer and technology nerd.
Here are some of my recent blog posts:
I want to download attachments from emails with the keyword "invoice" in the subject , no matter where it was. I tried the following command, " but it didn't work. The displayed message on the screen does not match.
attachment-downloader --host imap.gmail.com --username [email protected] --password password --date-after
"2023-07-07T00:00:00" --date-before="2023-07-31T23:59:00" --output /tmp --imap-folder Inbox --subject-regex "invoice"
2023-07-07 09:34:44,202 - INFO - Listing messages matching the following criteria: folder=Inbox, date__gt=2023-07-07, date__lt=2023-07-31
2023-07-07 09:34:44,500 - INFO - Fetch list of messages from folder 'Inbox'
2023-07-07 09:34:45,197 - INFO - Downloaded and parsed mail 'RMA invoice quotation' with 1 attachments
2023-07-07 09:34:45,198 - WARNING - Skipping message 'b'12632'' subject 'RMA invoice quotation' because it does not match invoice
but if I replace the regexp to RMA , then it works
attachment-downloader --host imap.gmail.com --username [email protected] --password password --date-after "2023-07-07T00:00:00" --date-before="2023-07-31T23:59:00" --output /tmp --imap-folder Inbox --subject-regex "RMA"
2023-07-07 09:34:09,012 - INFO - Listing messages matching the following criteria: folder=Inbox, date__gt=2023-07-07, date__lt=2023-07-31
2023-07-07 09:34:09,302 - INFO - Fetch list of messages from folder 'Inbox'
2023-07-07 09:34:09,983 - INFO - Downloaded and parsed mail 'RMA invoice quotation' with 1 attachments
2023-07-07 09:34:09,984 - INFO - Processing message 'b'12632'' subject 'RMA invoice quotation'
2023-07-07 09:34:09,984 - INFO - Downloading attachment '2023-07-06_10-33_d1kW1HER.png' to path /tmp/2023-07-06_10-33_d1kW1HER.png
any suggestions ?
Firstly, thank you for a fantastic tool. :)
Anyways this proposed feature would allow one to specify a relative time, eg "2 Months Ago" which would be a rolling window. That way additional client side logic is not needed if you run the task periodically and only want to process newish mails for performance reasons.
Hi,
Below is the error after reading about 25 emails. I am reading about 39K emails on an AOL imap server. It appear to fail when it hits an email with an attachment. I tried to edit line 118 to match the date format within AOL but could not get the system to download the attached file. Do you have any thoughts on why this may be happing? This looks like a great script and would love to see it collect all the files within my email. Thanks
_Traceback (most recent call last):
File "C:\python382\Scripts\attachment-downloader.py", line 118, in
parsed_message_date = datetime.datetime.strptime(sanitised_date, '%a, %d %b %Y %H:%M:%S %z')
File "c:\python382\lib_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "c:\python382\lib_strptime.py", line 349, in strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '10 Feb 2018 18:11:48 +0000' does not match format '%a, %d %b %Y %H:%M:%S %z'
It could be usefull to limit the search of the imap lib search function.
It is probably possible and I found this; I am not sure it helps:
https://stackoverflow.com/questions/2177306/imap-search-limit-the-number-of-messages-returned
I am thinking something like attachment-downloader --BEFORE 2018-01-01-17:30:30 --AFTER 2017-06-06-17:30:30 (or something similar).
The script was returning the error "dateutil.parser._parser.ParserError: Unknown string format: Wed, 27 Jul 2022 14:40:40 -0300 (GMT-03:00)" because of the "(GMT-03:00)".
Added "split" to extract only the default datetime format of the string:
message.date.split("(")[0]
attachment-downloader.txt]
Not really expecting a useful response, but just in case, I found that trying to filter on a folder named:
GERNews.2022.2022-05 Summer - 191
... failed with the message about search not being valid in the auth state.
However, changing the name of the folder to:
GERNews.2022_191
Made it work. I don't know why or what is going on here.
My IMAP server is Dovecot, I'm using latest (as of now) install of the module & deps, and it's on python3.9 running on a MacBook Pro M1.
This is the log:
2022-05-27 23:20:20,695 - INFO - Logging in to: 'xxx' as 'xxx'
2022-05-27 23:20:20,734 - INFO - Connected to IMAP Server with user xxx on xxx over SSL
2022-05-27 23:20:20,734 - INFO - Listing messages matching the following criteria: folder=GERNews.2022.2022-05 Summer - 191
2022-05-27 23:20:20,737 - INFO - Fetch list of messages from folder 'GERNews.2022.2022-05 Summer - 191'
Traceback (most recent call last):
File "/opt/homebrew/bin/attachment-downloader", line 112, in <module>
messages = mail.messages(**filter_options)
File "/opt/homebrew/lib/python3.9/site-packages/imbox/imbox.py", line 100, in messages
return messages_class(connection=self.connection,
File "/opt/homebrew/lib/python3.9/site-packages/imbox/messages.py", line 37, in __init__
self._uid_list = self._query_uids(**kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/imbox/messages.py", line 48, in _query_uids
_, data = self.connection.uid('search', None, query_)
File "/opt/homebrew/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imaplib.py", line 885, in uid
raise self.error("command %s illegal in state %s, "
imaplib.IMAP4.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED
Good job!
--filename-template.
--date-after.
Example:--date-after="{{date.strftime(%Y-%m-%dT00:00:00')}}"
import yt_dlp
ydl_opts = {
'format': format_selector,
}
From 2023 the OAuth2 is required by Microsoft. Is it possible to use the attachment-downloader in this environment?
Hi,
Sometimes it happens, that mail came without subject, than the script crash
2021-01-28 22:21:34,418 - INFO - Downloaded and parsed mail 'None' with 1 attachments
2021-01-28 22:21:34,419 - INFO - Mark UID 5 with \Seen FLAG
Traceback (most recent call last):
File "/home/andreas/.local/bin/attachment-downloader", line 71, in <module>
logging.info("Processing message '%s' subject '%s'", uid, message.subject)
AttributeError: 'Struct' object has no attribute 'subject'
Br
Andreas
"attachment-downloader --host imap.gmail.com --username [email protected] --password XXXXXXXX --imap-folder inbox --output ~\Desktop\F-ass"
I tried this code but always it open the source code in next file but not download the attachment
2021-12-30 17:14:14,603 - INFO - Processing message 'b'27982'' subject 'Watchguard'
2021-12-30 17:14:14,626 - INFO - Downloaded and parsed mail 'Watchguard' with 0 attachments
2021-12-30 17:14:14,627 - INFO - Processing message 'b'27983'' subject 'Watchguard'
2021-12-30 17:14:14,649 - INFO - Downloaded and parsed mail 'Watchguard' with 0 attachments
2021-12-30 17:14:14,650 - INFO - Processing message 'b'27984'' subject 'Watchguard'
2021-12-30 17:14:14,673 - INFO - Downloaded and parsed mail 'American School: 192.168.200.246 - System Alarm' with 0 attachments
2021-12-30 17:14:14,673 - ERROR - 'Struct' object has no attribute 'date'
Traceback (most recent call last):
File "/usr/local/bin/attachment-downloader", line 146, in
parsed_message_date = dateparser.parse(message.date)
AttributeError: 'Struct' object has no attribute 'date'
Traceback (most recent call last):
File "/usr/local/bin/attachment-downloader", line 146, in
parsed_message_date = dateparser.parse(message.date)
AttributeError: 'Struct' object has no attribute 'date'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/attachment-downloader", line 149, in
logging.error("Skipping message '%s' subject '%s' because date can not be parsed '%s'", uid, subject, message.date)
AttributeError: 'Struct' object has no attribute 'date'
This script is amazing! Works great for a digital picture frame. How can I specify multiple regular expression matches for the subject? I've tried using a pipe character to denote OR all inside both double and single quotes, but it does not work. Email clients on phones will often try to autocorrect the subject to proper capitalization and/or split the word "picframe" into "pic frame". I'd like to specify the following as an example:
picframe|Picframe|PicFrame|Pic Frame|pic frame
I am running the script on a Synology Server. Initially had zero issues and now getting the following output:
023-11-06 09:18:16,709 - INFO - Folders: ['Inbox']
2023-11-06 09:18:16,709 - INFO - Listing messages matching the following criteria: folder=Inbox
2023-11-06 09:18:16,738 - INFO - Fetch list of messages from folder 'Inbox'
2023-11-06 09:18:17,061 - ERROR - Failed to process messages for folder 'Inbox'
2023-11-06 09:18:17,061 - ERROR - invalid literal for int() with base 10: ''
Traceback (most recent call last):
File "/bin/attachment-downloader", line 190, in
for (uid, message) in messages:
File "/usr/lib/python3.8/site-packages/imbox/messages.py", line 55, in _fetch_email_list
yield uid, self._fetch_email(uid)
File "/usr/lib/python3.8/site-packages/imbox/messages.py", line 42, in _fetch_email
return fetch_email_by_uid(uid=uid,
File "/usr/lib/python3.8/site-packages/imbox/parser.py", line 155, in fetch_email_by_uid
email_object = parse_email(raw_email, policy=parser_policy)
File "/usr/lib/python3.8/site-packages/imbox/parser.py", line 212, in parse_email
attachment = parse_attachment(part)
File "/usr/lib/python3.8/site-packages/imbox/parser.py", line 122, in parse_attachment
filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value)
ValueError: invalid literal for int() with base 10: ''
2023-11-06 09:18:17,062 - INFO - Finished processing messages
I just did the update to the script and still has this output
Hi,
One additional error, I am getting, but not sure why.
The email B29 did not have an attachment, but others also do not have one
2021-01-28 22:38:51,879 - INFO - Processing message 'b'29'' subject 'Würden Sie uns auch bewerten? Semaf Electronics' Traceback (most recent call last): File "/home/andreas/.local/bin/attachment-downloader", line 69, in <module> for (uid, message) in messages: File "/home/andreas/.local/lib/python3.8/site-packages/imbox/messages.py", line 55, in _fetch_email_list yield uid, self._fetch_email(uid) File "/home/andreas/.local/lib/python3.8/site-packages/imbox/messages.py", line 42, in _fetch_email return fetch_email_by_uid(uid=uid, File "/home/andreas/.local/lib/python3.8/site-packages/imbox/parser.py", line 155, in fetch_email_by_uid email_object = parse_email(raw_email, policy=parser_policy) File "/home/andreas/.local/lib/python3.8/site-packages/imbox/parser.py", line 212, in parse_email attachment = parse_attachment(part) File "/home/andreas/.local/lib/python3.8/site-packages/imbox/parser.py", line 122, in parse_attachment filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value) ValueError: invalid literal for int() with base 10: ''
If I am deleting the “b29”, I am getting the same error on an other email:
2021-01-28 22:50:41,183 - INFO - Downloaded and parsed mail 'Fwd: Ihre Rechnung von ABC IN2021993' with 1 attachments 2021-01-28 22:50:41,183 - INFO - Mark UID 26 with \Seen FLAG 2021-01-28 22:50:41,195 - INFO - Processing message 'b'26'' subject 'Fwd: Ihre Rechnung von ABC IN2021993' 2021-01-28 22:50:41,196 - INFO - Downloading attachment 'IN2021993.pdf' to path /home/andreas/Downloads/mail/IN2021993.pdf 2021-01-28 22:50:41,196 - WARNING - Overwriting file: '/home/andreas/Downloads/mail/IN2021993.pdf' Traceback (most recent call last): File "/home/andreas/.local/bin/attachment-downloader", line 69, in <module> for (uid, message) in messages: File "/home/andreas/.local/lib/python3.8/site-packages/imbox/messages.py", line 55, in _fetch_email_list yield uid, self._fetch_email(uid) File "/home/andreas/.local/lib/python3.8/site-packages/imbox/messages.py", line 42, in _fetch_email return fetch_email_by_uid(uid=uid, File "/home/andreas/.local/lib/python3.8/site-packages/imbox/parser.py", line 155, in fetch_email_by_uid email_object = parse_email(raw_email, policy=parser_policy) File "/home/andreas/.local/lib/python3.8/site-packages/imbox/parser.py", line 212, in parse_email attachment = parse_attachment(part) File "/home/andreas/.local/lib/python3.8/site-packages/imbox/parser.py", line 122, in parse_attachment filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value) ValueError: invalid literal for int() with base 10: ''
Br
Andreas
Might be nice to allow option to not ignore existing files. This way one can run the script idempotently, and only new files will be added.
A nice side effect is it save bandwidth, keeps file dates in chronological order (like if you're running a daily chron job), and also doesn't trigger any file watching logic on the OS side.
Trying to access any of GMail's "subfolders" fails.
It seems this is due to GMail not using a actual folder structure but labels?
How to download attachments from a GMail label which would show up in GMail's search e.g. as "label:some-weird-thingies-going-on"?
Trying to set this up for a family member. This is the results of the log file.
2022-05-31 22:01:45,253 - INFO - Attachment Downloader - Version: 1.2.3 (Python: 3.7.3), OS: (Release: 5.10.103-v7+, Platform: Linux-5.10.103-v7$2022-05-31 22:01:45,272 - INFO - Logging in to: 'imap.gmail.com' as '[email protected]'
Traceback (most recent call last):
File "/home/xxx/.local/bin/attachment-downloader", line 86, in
starttls=starttls)
File "/home/xxx/.local/lib/python3.7/site-packages/imbox/imbox.py", line 35, in init
self.connection = self.server.connect(username, password)
File "/home/xxx/.local/lib/python3.7/site-packages/imbox/imap.py", line 33, in connect
self.server.login(username, password)
File "/usr/lib/python3.7/imaplib.py", line 596, in login
typ, dat = self._simple_command('LOGIN', user, self._quote(password))
File "/usr/lib/python3.7/imaplib.py", line 1196, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/usr/lib/python3.7/imaplib.py", line 960, in _command
arg = bytes(arg, self._encoding)
UnicodeEncodeError: 'ascii' codec can't encode character '\u201c' in position 1: ordinal not in range(128)
Hello
I am trying to run the attachment downloader, but unfortunately it is not working for me, not sure what I am doing wrong...
Installation worked fine with pip and then I tried running it
`import attachment_downloader
attachment_downloader --host=imap.gmail.com --username=user --password='password' --output='C:\test'`
It gives the following error:
SyntaxError: can't assign to operator
Hi,
Could you add from_email to the filename template?
Thank you!
I have a problem with the script, it is failing randomly with some attachments and I don't know why, I can't find any logical reason, at first I thought it was failing because of strange characters that were not standard ASCII, but now I see that some attachments with spaces, accents, etc... download them and others don't.
These are the failures when I run the script, (I have modified some data for security)
I have the last versions python in a Windows 2012 server
C:\Users\Administrador.empresa\AppData\Local\Programs\Python\Python39\Scripts>py .\attachment-downloader --host 192.168.58.3 --username facturas --password password --imap-folder Inbox --output d:\Factu2 --unsecure --date-after="2021-11-30T14:00:00" --delete --delete-copy-folder Inbox/Procesado 2021-11-30 18:14:21,735 - INFO - Logging in to: '192.168.58.3' as 'facturas' 2021-11-30 18:14:22,609 - INFO - Connected to IMAP Server with user facturas on 192.168.58.3 2021-11-30 18:14:22,609 - INFO - Listing messages matching the following criteri a: folder=Inbox, date__gt=2021-11-30 2021-11-30 18:14:22,609 - INFO - Fetch list of messages from folder 'Inbox' 2021-11-30 18:14:22,640 - INFO - Downloaded and parsed mail 'iberdon INFORMS' with 0 attachments 2021-11-30 18:14:22,640 - WARNING - Skipping message 'b'29656'' subject 'IBERDRO LA INFORMS' because it is before 2021-11-30 14:00:00+00:00 2021-11-30 18:14:22,656 - INFO - Downloaded and parsed mail 'ASUNTO: EXPEDIENTE PENDIENTE DE PAGO' with 0 attachments 2021-11-30 18:14:22,656 - WARNING - Skipping message 'b'29657'' subject 'ASUNTO: EXPEDIENTE PENDIENTE DE PAGO' because it is before 2021-11-30 14:00:00+00:00 2021-11-30 18:14:22,718 - INFO - Downloaded and parsed mail 'Facturas Noviembre 2021' with 2 attachments 2021-11-30 18:14:22,718 - WARNING - Skipping message 'b'29661'' subject 'Factura s Noviembre 2021' because it is before 2021-11-30 14:00:00+00:00 2021-11-30 18:14:22,734 - INFO - Downloaded and parsed mail 'ASUNTO: EXPEDIENTE PENDIENTE DE PAGO' with 0 attachments 2021-11-30 18:14:22,734 - INFO - Processing message 'b'29663'' subject 'ASUNTO: EXPEDIENTE PENDIENTE DE PAGO' 2021-11-30 18:14:22,765 - INFO - Downloaded and parsed mail 'Factura Servicios A AAA zacilities, S.L.U.' with 1 attachments 2021-11-30 18:14:22,765 - INFO - Processing message 'b'29664'' subject 'Factura Servicios AAA zacilities, S.L.U.' 2021-11-30 18:14:22,765 - INFO - Downloading attachment '' to path d:\Factu2\ 2021-11-30 18:14:22,765 - ERROR - [Errno 2] No such file or directory: 'd:\\Fact u2\\' Traceback (most recent call last): File "C:\Users\Administrador.empresa\AppData\Local\Programs\Python\Python39\S cripts\attachment-downloader", line 182, in <module> with open(download_path, "wb") as fp: FileNotFoundError: [Errno 2] No such file or directory: 'd:\\Factu2\\' 2021-11-30 18:14:22,765 - ERROR - Error saving file. Continuing... 2021-11-30 18:14:22,796 - INFO - Downloaded and parsed mail 'Factura Servicios A AAA zacilities, S.L.U.' with 1 attachments 2021-11-30 18:14:22,796 - INFO - Processing message 'b'29665'' subject 'Factura Servicios AAA zacilities, S.L.U.' 2021-11-30 18:14:22,796 - INFO - Downloading attachment '' to path d:\Factu2\ 2021-11-30 18:14:22,796 - ERROR - [Errno 2] No such file or directory: 'd:\\Fact u2\\' Traceback (most recent call last): File "C:\Users\Administrador.empresa\AppData\Local\Programs\Python\Python39\S cripts\attachment-downloader", line 182, in <module> with open(download_path, "wb") as fp: FileNotFoundError: [Errno 2] No such file or directory: 'd:\\Factu2\\' 2021-11-30 18:14:22,812 - ERROR - Error saving file. Continuing... 2021-11-30 18:14:22,812 - INFO - Downloaded and parsed mail 'ASUNTO: EXPEDIENTE PENDIENTE DE PAGO' with 0 attachments 2021-11-30 18:14:22,812 - INFO - Processing message 'b'29666'' subject 'ASUNTO: EXPEDIENTE PENDIENTE DE PAGO' 2021-11-30 18:14:22,827 - INFO - Finished processing messages 2021-11-30 18:14:22,827 - INFO - Logging out of: 192.168.58.3 2021-11-30 18:14:22,827 - INFO - Disconnected from IMAP Server [email protected]. 58.3 2021-11-30 18:14:22,827 - INFO - Done
I have latest version and getting on all messages above error.
python-dateutil = 2.8.1-1.24
Hi James, I was alerted by a few people (and just tried it myself) that the pip install attachment-downloader
command results in a Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-IFS025/attachment-downloader/
message.
I just tested it with Buster on a Pi4. Has anything changed that has come to your attention?
Gmail seems to be erroring when we define an imap folder that does not exist. Maybe check if the folder exists and return a clearer error?
Traceback (most recent call last):
File "/var/services/homes/dicarsio/.local/bin/attachment-downloader", line 113, in <module>
messages = mail.messages(**filter_options)
File "/var/services/homes/dicarsio/.local/lib/python3.8/site-packages/imbox/imbox.py", line 100, in messages
return messages_class(connection=self.connection,
File "/var/services/homes/dicarsio/.local/lib/python3.8/site-packages/imbox/vendors/gmail.py", line 39, in __init__
super().__init__(connection, parser_policy, **kwargs)
File "/var/services/homes/dicarsio/.local/lib/python3.8/site-packages/imbox/messages.py", line 37, in __init__
self._uid_list = self._query_uids(**kwargs)
File "/var/services/homes/dicarsio/.local/lib/python3.8/site-packages/imbox/messages.py", line 48, in _query_uids
_, data = self.connection.uid('search', None, query_)
File "/usr/lib/python3.8/imaplib.py", line 876, in uid
raise self.error("command %s illegal in state %s, "
imaplib.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED
Sample command:
attachment-downloader --host=$EMAIL_HOST --username=$EMAIL_USERNAME --password=$EMAIL_PASSWORD \
--imap-folder=$EMAIL_IMAP_FOLDER --output=$EMAIL_DEST_FOLDER --date-after=$START_DATE --date-before=$END_DATE \
--filename-template="{{ date.strftime('%Y%m%d %H%M%S') }} {{ attachment_name }}"
Thanks,
C.
I have an imap box with an attachment which is not recognized by parser an so not downloaded.
The attachment is a pdf file.
Log:
2022-04-13 21:54:53,468 - INFO - Attachment Downloader - Version: 1.2.2 (Python: 3.7.3), OS: (Release: 5.10.0-0.bpo.8-amd64, Platform: Linux-5.10.0-0.bpo.8-amd64-x86_64-with-debian-10.12)
2022-04-13 21:54:53,483 - INFO - Logging in to: 'xxxx' as 'xxxxxxx'
2022-04-13 21:54:53,701 - INFO - Connected to IMAP Server with user xxxxx on xxxxx over SSL
2022-04-13 21:54:53,701 - INFO - Listing messages matching the following criteria: folder=Inbox
2022-04-13 21:54:53,734 - INFO - Fetch list of messages from folder 'Inbox'
2022-04-13 21:54:54,141 - INFO - Downloaded and parsed mail 'SUBJECTXXXX' with 0 attachments
2022-04-13 21:54:54,144 - INFO - Processing message 'b'170'' subject 'dfjhjfdhfjdhfjdhfjdhjf'
2022-04-13 21:54:54,144 - INFO - Finished processing messages
2022-04-13 21:54:54,144 - INFO - Logging out of: xxxxx
2022-04-13 21:54:54,208 - INFO - Disconnected from IMAP Server xxxxxxxxx
2022-04-13 21:54:54,208 - INFO - Done
Thx Wolfgang
Currently attachments with the same name in different mails will be overridden. Is it possible to have an option that prefixes the attachments with a Message ID (e.b.) or to put them in a separate folder?
It is possible to implement filetype filter?
Is there a way to influence the log level? I would like to output only everything from "Warning".
Thank you.
I use Wolfgang's gmail script to add all new content to my frame. I now see that I need to transition to this service. Thanks for fixing the upcoming problem.
I was starting to explore modifying the gmail script to have the script call a IPTC tag editor to add a comment tag that is contained in the email. The comment could either be in the subject line deleted by a character such as caption or possibly be in the body text.
Goal would be to call either the iptcinfo3 function info['caption/abstract'] = 'Witty caption here' or another library such as exiv2: exiv2 -M"add Iptc.Application2.Caption caption" filename once the file is detached and stored.
Is this something you are willing to add? If not, I think I might be able to use the filename template to capture the subject in the filename and then have another script walk through the import folder, parts the filename and make the change.
Used pip install attachment-downloader to install and received error.
pi@raspberrypi:~ $ pip install attachment-downloader
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting attachment-downloader
Downloading https://files.pythonhosted.org/packages/1f/6f/2b07c1ccc7d009a039fbf7cb1173ae06f0d58ba9266a7c1494a6826ea9b0/attachment-downloader-1.2.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-7GnDBu/attachment-downloader/setup.py", line 5, in
from attachment_downloader.version_info import Version
File "attachment_downloader/version_info.py", line 17
file.write(f'ATTACHMENT_DOWNLOADER_VERSION = "{version}"\n')
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-7GnDBu/attachment-downloader/
Hello,
first of all thank you for this program.
Currently there seems to be a problem when I'm using non ASCII character in the pdf-file name. For example "ß", "ä", "ö", "ü"
There is also an error message in the log. The file name was "Saturn Bestellbestätigung.pdf":
--- Logging error ---
Traceback (most recent call last):
File "/volume2/@appstore/py3k/usr/local/lib/python3.5/logging/__init__.py",
line 982, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 75: ordinal not in range(128) Call stack:
File "/volume2/scripts/env/bin/attachment-downloader", line 83, in <module>
logging.info("Downloading attachment '%s' to path %s", attachment.get('filename'), download_path)
Message: "Downloading attachment '%s' to path %s"
Arguments: ('Saturn Bestellbest\xe4tigung.pdf', '/volume2/homes/user/_OCR/Saturn Bestellbest\xe4tigung.pdf')
2020-10-16 09:30:03,345 - ERROR - 'ascii' codec can't encode character '\xe4' in position 77: ordinal not in range(128) Traceback (most recent call last):
File "/volume2/scripts/env/bin/attachment-downloader", line 85, in <module>
if os.path.isfile(download_path):
File "/volume2/@appstore/py3k/usr/local/lib/python3.5/genericpath.py",
line 30, in isfile
st = os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 77: ordinal not in range(128)
2020-10-16 09:30:03,346 - ERROR - Error saving file. Continuing...
2020-10-16 09:30:03,346 - INFO - Finished processing messages
It would be great if you could provide a fix for it.
Thank you in advance.
Hi, when I try to run the attachment-downloader I get the error bellow:
2021-08-10 12:02:35,616 - WARNING - Overwriting file: '/COLABORADORES/1111/202105-2181993041.pdf'
2021-08-10 12:02:35,622 - INFO - Downloaded and parsed mail 'Recibo de pagamento tipo Recibo Mensal ref. 07/2021' with 1 attachments
2021-08-10 12:02:35,622 - ERROR - 'Struct' object has no attribute 'date'
Traceback (most recent call last):
File "/usr/local/bin/attachment-downloader", line 146, in
parsed_message_date = dateparser.parse(message.date)
AttributeError: 'Struct' object has no attribute 'date'
Traceback (most recent call last):
File "/usr/local/bin/attachment-downloader", line 146, in
parsed_message_date = dateparser.parse(message.date)
AttributeError: 'Struct' object has no attribute 'date'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/attachment-downloader", line 149, in
logging.error("Skipping message '%s' subject '%s' because date can not be parsed '%s'", uid, subject, message.date)
AttributeError: 'Struct' object has no attribute 'date'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.