0

I am trying to read email body As bellow but getting junk characters

for account in EmailsAccounts:
    print(account)
    inbox = outlook.Folders(account).Folders('Inbox')
    messages=inbox.Items
    print(len(messages))
    for mail in messages:
        body = mail.Body
        print(body.encode('utf-8'))
Dinesh Chowdary
  • 252
  • 2
  • 3

1 Answers1

0

If the problem is related to encoding message bodies, try to use the following code instead:

print (mail.Body.encode('utf8'))

See Is there a way to get around unicode issues when using win32api/com modules in python 3? for more information.

If it is another problem I'd suggest check the message type - an Outlook folder may contain different kind of items such as appointments, tasks, documents or mail items.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • using above solution i am getting hex character as bellow b'\xe6\xa0\ , is there way to convert in text formate – Dinesh Chowdary Feb 18 '22 at 18:02
  • It makes sense to check out how it works with VBA macros. Do you get the same picture? – Eugene Astafiev Feb 18 '22 at 20:00
  • 1
    bellow thread is solving in VBA same solution i am looking python https://answers.microsoft.com/en-us/outlook_com/forum/all/problem-in-vba-reading-text-from-body-of-out-of/1d8ca369-a4c0-41da-9d28-3f490de3ed8c – Dinesh Chowdary Feb 24 '22 at 13:44