Python : How can I access Lotus Notes 8.5 Inbox to read emails

J.C Julien

I want to make an script in python that reads mails from Lotus Notes 8.5 and then create for each email an issue in jira but it returns me this error when I try to read the mails from Lotus:

Traceback (most recent call last):
File "", line 46, in <module>
File "", line 39, in main
folder = notesDatabase.GetView('$Inbox')
File "C:\Python27\lib\site-packages\win32com\gen_py\29131520-2EED-1069-BF5D-00", line 1849, in GetView
ret = self._oleobj_.InvokeTypes(1610743866, LCID, 1, (9, 0), ((8, 1),),pName

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'NotesDatabase',
u'Database  server_name!!C:\\Users\\MYNAME\\AppData\\Local\\Lotus\\Notes\\Data\\ma
il202\\myname.nsf has not been opened yet', None, 0, -2147217441), None)

here is my .py file

import win32com.client
import pywintypes
import getpass

def main():
    # Get credentials
    mailServer = 'server_name' 
    mailPath = 'C:\Users\MYNAME\AppData\Local\Lotus\Notes\Data\mail202\myname.nsf'

    mailPassword = ''
    # Connect
    notesSession = win32com.client.Dispatch('Lotus.NotesSession')

    notesDatabase = notesSession.GetDatabase(mailServer, mailPath)

    # Get a list of folders
    folder = notesDatabase.GetView('$Inbox')
    document = folder.GetFirstDocument()

if __name__ == "__main__":
Hugh Bothwell

Looking at

The full filepath (e.g. "C:\notes\data\r_apps\haha.nsf") may optionally be used when accessing local databases on a workstation. If you specify a server name, however, or if the code is running on a server, you must use the path relative to the Notes data directory ("r_apps\haha.nsf").

I suggest either (a) not specifying a server or (b) only giving a relative path, ie mailPath = r'mail202\myname.nsf'.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


How can I read the contents of an URL with Python?

How can I read keyboard input in Python

How can I access another user's resources (specifically emails) using Microsoft Graph in an MVC app?

How can I restrict access to maintain notes and attachments to the Owner of the record?

How can I display dialog list in web browser (HTML) so that user can select information from Address Book in Lotus Notes

Read All Categories from Lotus Notes

How do I mark mail as read in Lotus Notes without actually opening the email?

How do I move emails from a folder to the inbox in Outlook?

How do I change the default browser in lotus notes when opening links in emails?

How can I open a relocated ARCHIVE.NSF file in Lotus Notes?

Lotus Notes Rules "Mark as Read"?

How can I reduce the volume of DenyHosts emails?

How can I access a Lotus Notes Database from PHP5

lotus notes/ibm notes/domino 9 - how make emails read/unread programmatically in lotus script?

How can I filter emails by IP in Thunderbird?

In Lotus Notes 9 How do you manually run rules you've written on your inbox, without installing any other plugins / software?

Can't create Lotus Notes objects

How Do I write an IBM (Lotus) Notes Client?

Sending emails with lotus notes using windows command line

Lotus Notes: how can i extract number in a specific position after comma

How do I fetch emails leaving them read/unread in Python?

Lotus Notes - mailto command : select inbox

can i see lotus notes hidden-document with reader field

Read emails from Inbox gmail

How to forward mails in lotus notes

[VBA]Lotus Notes Inbox order

How to get document when I select a document in IBM Lotus Notes

How do I filter inbox and only download emails that have attachments

VSTO Outlook, not able to read bounce back emails in inbox