i'm writing a python script which reads emails from Outlook then extract the body The problem is that when it reads an email answer, the body contains the previous emails. Is there away to avoid that and just extract the body of the email.
This is a part of my code :
import requests
import json
import base64
utlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
folder = outlook.Folders.Item("UGAP-AMS-L2")
inbox = folder.Folders.Item("Inbox")
mails = inbox.Items
mails.Sort("[ReceivedTime]", False)
for mail in mails:
if mail.UnRead == True :
print(" mail.Body")
This is what i get :
-Email body of the current email-
De : "tracker@gmail.fr" tracker@gmail.fr
Date : vendredi 21 mai 2021 à 08:44
À : Me Me@outlook.com
Objet : object
-body of previous email-