I am working on a script that is sending all attachments of the e-mails I open to a specific path. To summarize, the main code I am using would be the following:
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem('path to .msg i want to open')
attachments = msg.Attachments
attachment_no = len([x for x in attachments])
for x in range(1, attachment_no):
attachment = attachments.Item(x)
attachment.SaveASFile('path' + str(attachment))
It works well, I do not get any errors, but not as expected. Instead of saving the attached files, let's say PDFs, the script is saving the files that are embedded in the body of the e-mail, i.e. pictures, the sender signature and so on. So instead of attached PDFs I get some .jpg files.
What I am doing wrong here?
Thank you in advance!