1

The code

#!/usr/bin/env python
from exchangelib import ServiceAccount, Configuration, Account, DELEGATE

import os
import logging
from config import cfg
logging.basicConfig()

credentials = ServiceAccount(username=cfg['imap_user'],
                             password=cfg['imap_password'])

config = Configuration(server=cfg['imap_server'], credentials=credentials)
account = Account(primary_smtp_address=cfg['smpt_address'], config=config,
                  autodiscover=False, access_type=DELEGATE)
unread = account.inbox.filter(is_read=False)   # returns unread emails
for msg in unread:
    print("last_modified_time={}".format(msg.last_modified_time))
    print("datetime_sent     ={}".format(msg.datetime_sent))
    print("#" * 80)

gives me the output

author            =Mailbox('Martin Thoma', 'martin.thoma@abc.def', 'OneOff', None)
sender            =Mailbox('Martin Thoma', 'martin.thoma@abc.def', 'OneOff', None)
################################################################################
author            =Mailbox('Martin Thoma', 'info@hij.klm', 'OneOff', None)
sender            =Mailbox('Martin Thoma', 'info@hij.klm', 'OneOff', None)
################################################################################

Are author and sender always the same?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • I think they are semantically different. The 'sender' is the actual sender of the message, the 'author' is the person who wrote the message. They can be different people. – ant1g Aug 01 '17 at 10:07
  • 3
    Correct. exchangelib just mimics the same fields in EWS (although `author` is called `From` in EWS). – Erik Cederstrand Aug 01 '17 at 15:11

0 Answers0