Python Forum
Details of attachment files in a msg file such as file names save into a python list - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Details of attachment files in a msg file such as file names save into a python list (/thread-22197.html)



Details of attachment files in a msg file such as file names save into a python list - klllmmm - Nov-03-2019

I want to get details of attachments in an email file (msg format).
1. I would like to get attachment names into a list.
Currently i can only get True or False value, indicating whether there is an attachment or not.

Sample email file is uploaded to OneDrive- https://1drv.ms/u/s!An03iU493hAgnj0tG51D58J0S40m?e=tzBT5k
import win32com.client

outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg=outlook.OpenSharedItem(r'''C:\Users\Desktop\Downloads\Test_MSGfiles.msg''')

msg_AttachmentsList = msg.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0E1B000B")
2. In case if possible can we get attachment file sizes into a list and also can we save attachments into a folder as well.

Appreciate your thoughts on this.
Thanks,
klllmmm


RE: Details of attachment files in a msg file such as file names save into a python list - MckJohan - Nov-05-2019

use other method
for i in msg.Attachments:
    print(i)



RE: Details of attachment files in a msg file such as file names save into a python list - klllmmm - Nov-12-2019

(Nov-05-2019, 06:22 AM)MckJohan Wrote: use other method
for i in msg.Attachments:
    print(i)

This works, Thank you so much!