Search code examples
pythoncomlotus-noteslotus-dominolotusscript

reading Lotus Notes documents via COM


I am trying to read e-mails in a Lotus Notes database via python and com. (using pythonwin and win32com)

I can connect to the database and read NotesDocument items but

doc = folder.GetFirstDocument()
doc.GetItemValue('Body')

returns the plain text contents of the email. I can get the headers, subject, date, etc but body is plaintext. I'm trying to fetch the HTML source of the email which includes links and other formatting. I know the stuff is there because within Notes I can view-->show--> page source.

I've tried

doc.GetMIMEEntity('Body')

but this returns None.


Solution

  • Try adding this line right after where you get the session:

    session.ConvertMIME = False
    

    Update:

    Barry commented that it worked this way:

    doc.GetFirstItem("Body").GetMIMEEntity()