Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearly documented reading of emails functionality with python win32com outlook

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.

like image 705
Phoenix Avatar asked Apr 02 '14 13:04

Phoenix


People also ask

Can Python read emails from Outlook?

Learn how you can use IMAP protocol to extract, parse and read emails from outlook, aol, office 365 and other email providers as well as downloading attachments using imaplib module in Python.

How do I use win32com client in Python?

Run ' win32com\client\makepy.py ' (eg, run it from the command window, or double-click on it) and a list will be presented. Select the Type Library ' Microsoft Word 8.0 Object Library ' From a command prompt, run the command ' makepy.py "Microsoft Word 8.0 Object Library" ' (include the double quotes).

What is win32com Python?

win32com.server packageSupport for COM servers written in Python. The modules in this package provide most of the underlying framework for magically turning Python classes into COM servers, exposing the correct public methods, registering your server in the registry, etc.


1 Answers

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
like image 97
Genome Avatar answered Sep 18 '22 12:09

Genome