Reputation: 33
I am using Python win32com to parse email from outlook . I am able to fetch email from the outlook folder , but I not able to verify whether the email is a reply or response or a forwarded message , I need to check whether the email reiceved is the reply of the previous mail (if yes then find the original mail) or email is the forwarded message. I am using following code to fetch emails from outlook.
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox=outlook.Folders['[email protected]'].Folders['Inbox'].Folders['abc']
messagesReach = inbox.Items
for message in messagesReach:
if message.Unread==True:
print(message.body)
Upvotes: 0
Views: 4077
Reputation: 33
Hi the header is ConversationID
and can be used as message.ConversationID
refer https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem_properties.aspx
Upvotes: 1
Reputation: 66
You could try to read the first three characters of the subject, and determine if it has the "Re:"-prefix and therefore is a reply. This should be the case most times.
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.Folders["[email protected]"].Folders["Inbox"].Folders["abc"]
messagesReach = inbox.Items
for message in messagesReach:
if message.Unread == True:
if message.Subject[:3] == "Re:":
print(message.body)
Upvotes: 0