Python Forum
Details of attachment files in a msg file such as file names save into a python list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Details of attachment files in a msg file such as file names save into a python list
#1
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
Reply
#2
use other method
for i in msg.Attachments:
    print(i)
Reply
#3
(Nov-05-2019, 06:22 AM)MckJohan Wrote: use other method
for i in msg.Attachments:
    print(i)

This works, Thank you so much!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python openyxl not updating Excel file MrBean12 1 251 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Unable to download TLS Report attachment blason16 6 456 Feb-26-2024, 07:36 AM
Last Post: Pedroski55
  Python logging RotatingFileHandler writes to random file after the first log rotation rawatg 0 341 Feb-15-2024, 11:15 AM
Last Post: rawatg
  File loop curiously skipping files - FIXED mbk34 10 686 Feb-10-2024, 07:08 AM
Last Post: buran
  Copy Paste excel files based on the first letters of the file name Viento 2 349 Feb-07-2024, 12:24 PM
Last Post: Viento
  Open/save file on Android frohr 0 281 Jan-24-2024, 06:28 PM
Last Post: frohr
  connect sql by python using txt. file dawid294 2 382 Jan-12-2024, 08:54 PM
Last Post: deanhystad
  file open "file not found error" shanoger 8 946 Dec-14-2023, 08:03 AM
Last Post: shanoger
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,316 Nov-09-2023, 10:56 AM
Last Post: mg24
  Search Excel File with a list of values huzzug 4 1,148 Nov-03-2023, 05:35 PM
Last Post: huzzug

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020