Python Forum

Full Version: Details of attachment files in a msg file such as file names save into a python list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!An03iU493hAgnj0tG51D...m?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
use other method
for i in msg.Attachments:
    print(i)
(Nov-05-2019, 06:22 AM)MckJohan Wrote: [ -> ]use other method
for i in msg.Attachments:
    print(i)

This works, Thank you so much!