Clearly documented reading of emails functionality with python win32com outlook

Phoenix picture Phoenix · Apr 2, 2014 · Viewed 60.7k times · Source

I'm trying to understand outlook interaction through win32com better. I've been unable to find clear documentation that allows me to utilise win32com to read emails effectively, from my current investigation it seems like a fairly regular sentiment by users. Thus comes the following information and request:

Could someone;

1. Give a link to the location of clear documentation (if it exists)

2. Expand on the below

Below is the current functionality I've found based on reading other peoples code.

Take the below code:

import win32com

outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

inbox=outlook.GetDefaultFolder(6)

messages=inbox.Items

for message in messages:
    attachments = message.attachments

    for attachment in attachments:
        pass

The objects used above have the following functionality that I'm aware of:

inbox -

.Folders
.Items

messages -

.GetFirst()
.GetLast()
.GetNext()
.GetPrevious()
.Attachments

message -

.Subject
.Body
.To
.Recipients
.Sender
.Sender.Address

attachments -

.item()
.Count

attachment -

.filename

If you know of any more functionality then please add to this in your answers.

Answer

Genome picture Genome · Apr 2, 2014

The visual basic for applications reference is your friend here. Try starting with this link...

Interop Outlook Mailitem Properties

For instance I can see that message will probably have additional properties than what you listed above. For example.

  • message.CC
  • message.Importance
  • message.LastModificationTime