Python Forum
How to read and save specific outlook email into csv - 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: How to read and save specific outlook email into csv (/thread-9889.html)



How to read and save specific outlook email into csv - Prince_Bhatia - May-03-2018

Hi,

I receive the certain outlook email on daily basis which looks like a table with the subject : Creation Report - 30/04/2018(these dates change daily)

so far i tried this :

import win32com.client
import os
outlook=win32com.client.Dispatch("Outlook.Application").GetNameSpace("MAPI")
inbox=outlook.GetDefaultFolder(6) #Inbox default index value is 6
message=inbox.Items
message2=message.GetLast()
subject=message2.Subject("XID Creation Report")
body=message2.body
date=message2.senton.date()
sender=message2.Sender
attachments=message2.Attachments
print(subject)
print(body)
print(sender)
print(attachments.count)
print(date)
Since i dont have much experience in outlook scraping , how can i scrape this subject email from outlook and save it into excel

since body is case sensitive, i cant show it but it is a table.

can anyone please help?