1

I want to extract received date and time for each e-mail in my inbox, but I'm getting microsecond error.

How to get outlook email time without microseconds? Is there a way to strip it?

import win32com.client
import csv
import pandas as pd

head = [("Subject","Body","receivedtime")]  

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
root_folder = outlook.Folders.item(1)
inbox2020= root_folder.Folders["Caixa de Entrada 2020"]
messages = inbox2020.Items

message = messages.GetFirst()
print (message.receivedtime)
AMC
  • 2,642
  • 7
  • 13
  • 35
  • Does this answer your question? [Python datetime to string without microsecond component](https://stackoverflow.com/questions/7999935/python-datetime-to-string-without-microsecond-component) – Uyghur Lives Matter Apr 14 '20 at 21:13
  • Hi, no i think my problem was in mapi commands, now i'm using senton instead of receivedtime, and all works fine, ty for help – Adriano Ribeiro Apr 15 '20 at 00:19
  • _but I'm getting microsecond error._ What does that mean? Is your program throwing an actual exception? – AMC Apr 15 '20 at 00:57
  • Hi AMC, when debuging the code one of me lines display this error: Microsecond must be in 0..999999. But is solved i changed message.receivedtime for message.senton, that way mapi dont get microseconds. – Adriano Ribeiro Apr 15 '20 at 14:17

1 Answers1

0

Find solution using senton instead of receivedtime.