Lotus notes script example

This is an example of how to access lotus email with python, please comment

from win32com.client import Dispatch
import smtplib

session = Dispatch(‘Lotus.Notessession’)
session.Initialize('xxxxx')
db = session.getDatabase("",'xxxxx\xxxxxx.nsf')
print db.Title

view = db.GetView('$Inbox')
print view.name
doc = view.GetFirstDocument
record = doc.GetItemValue('Body')
print doc.GetItemValue('Subject')
for line in record :
    print line
print '##########################################################'
loop=0
while loop<4:
    doc = view.GetNextDocument(doc)
    record = doc.GetItemValue('Body')
    print doc.GetItemValue('Subject')
    for line in record :
        print line
    print '##########################################################'
    loop=loop+1

3 Replies to “Lotus notes script example”

  1. The Code is not working out of the box for me.
    the line
    session = Dispatch(‘Lotus.NotesSession’)
    had to be changed to
    session = Dispatch(‘Lotus.Notessession’) #note the small ‘s’

    and
    ‘view.getFirstDocument’ has to be called without ‘()’

    the rest works as intended. 🙂
    JD

  2. I did just the same, but I received data in encoded or encrypted form, how can i decode or decrypt the data?
    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.