473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python and Lotus Notes

Hello everyone. I have to get data from Lotus Notes and i curious is it
possible doing it with Python. I heard that Lotus Notes using COM, so
the Python does so maybe it can be done? Anyone have any experiences
doing that?
Ane help will by apreciated
Gregor
Nov 2 '05 #1
5 11658

Grzegorz Slusarek wrote:
Hello everyone. I have to get data from Lotus Notes and i curious is it
possible doing it with Python. I heard that Lotus Notes using COM, so
the Python does so maybe it can be done? Anyone have any experiences
doing that?
Ane help will by apreciated


Yes, it's pretty simple. Quick example:

from win32com.client import Dispatch
session = Dispatch('Lotus .NotesSession')
session.Initial ize(MY_NOTES_PA SSWORD)

db = session.getData base(SERVER_NAM E, DB_NAME)
...

The LotusScript reference guide is almost completely applicable to
Notes via COM.

It can be useful to define some helper functions to make working with
Notes a bit easier. For example, this is the (very clunky) way to
iterate all documents in a Notes database, without helper code:

view = db.getView('Imp ortant Docs')
doc = db.getFirstDocu ment()
while doc:
do_something_wi th(doc)
doc = view.getNextDoc ument(doc)

You probably recognize the pattern from any LotusScript you've written.
(It sure is easy to forget that last line...)

But Python gives you far better control structures, like generators.
It's worthwhile to define a few helper functions like this, in a common
module:

def iterateDocument s(docs):
doc = docs.getFirstDo cument()
while doc:
yield doc
doc = docs.getNextDoc ument(doc)

Then you can write much cleaner code, like this:

for doc in iterateDocument s(view):
do_something_wi th(doc)

Similarly you can write iterator functions for traversing databases,
ACL entries, etc.

I also find these two defnitions useful:

def get(doc, attr):
return doc.getItemValu e(attr)

def get1(doc, attr):
return get(doc, attr)[0]

because it's a lot easier to write:

user_name = get1(user_doc, 'FullName')

than:

user_name = user_doc.getIte mValue('FullNam e')[0]

Note that the attribute-access style that LotusScript allows, e.g.
"user_doc.FullN ame(0)" does not work in Python/COM, hence you'll need
getItemValue(), replaceItemValu e(), etc.. You could write a wrapper for
the NotesDocument class that would give you attributes like this.
Personally, I find that to be more trouble than it's worth, but your
needs be very different.

Last warning: once you've tried using Python and COM, you'll scream
whenever you have to write LotusScript, and you'll wish like crazy that
Notes/Domino supported Python as a native scripting language. :-)
Jython kind of works, but I never got it happily running for
server-side code, alas.

Graham

Nov 2 '05 #2
thank you Graham
Now I know how to get it thru
And i have last question is it possible send mail from Lotus via
Python/COM?
Once Again Thanks
Nov 3 '05 #3

The second line of your code is already a show stopper in my case:

from win32com.client import Dispatch
session = Dispatch('Lotus .NotesSession')
session.Initial ize('my_secret_ passwort')

When started, ends:

File
"C:\Python24\Li b\site-packages\python win\pywin\frame work\scriptutil s.py",
line 310, in RunScript
exec codeObject in __main__.__dict __
File "C:\temp\notes_ init.py", line 3, in ?
session.Initial ize('my_secret_ passwort')
File "c:\Python24\li b\site-packages\win32c om\client\dynam ic.py", line
489, in __getattr__
raise AttributeError, "%s.%s" % (self._username _, attr)
AttributeError: Lotus.NotesSess ion.Initialize

It worked before though with Version 5.x of Notes. In Notes Version 6.X
they introduced the session.Initial ize() - that was the point, when I
couldn't create an instance anymore. I found no hint on the net... Do you
have any idea what is going wrong here?

Regards,
Marco

Nov 4 '05 #4
Marco Aschwanden wrote:
The second line of your code is already a show stopper in my case:

from win32com.client import Dispatch
session = Dispatch('Lotus .NotesSession')
session.Initial ize('my_secret_ passwort')

When started, ends:
[snip]
AttributeError: Lotus.NotesSess ion.Initialize

It worked before though with Version 5.x of Notes. In Notes Version 6.X
they introduced the session.Initial ize() - that was the point, when I
couldn't create an instance anymore. I found no hint on the net... Do you
have any idea what is going wrong here?


I'm using 6.x here, so that's not the problem.

Is there any chance you have an old gen_py file in your path? E.g.,
does re-running the PythonWin "makepy" utility again make a difference?
Just a thought, but something might be "hard-coded" to your earlier 5.x
COM interface, and gen_py would be a likely suspect.

Also, If you have another language that you can use to do COM, e.g.
Visual Basic (in any of the MS Office apps, or in Visual Studio),
verify that you can create a Lotus.NotesSess ion using those
environments as well. It might be a lower-level (non-Python-related)
problem.

Graham

Nov 4 '05 #5
I have had success with jython using the notes.jar classes, for
example:

import lotus.domino
import java.io
import java.net
import java.lang
import java.util

lotus.notes.Not esThread.sinitT hread()
S = lotus.notes.Ses sion.newInstanc e();
db=S.getDatabas e("server/domain","domlog .nsf")
agent=db.getAge nt("DeleteOldDo cs")
for x in range(50):
print x
result=agent.ru nOnServer()
print "res %d" % result

Nov 4 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
15173
by: Sateesh | last post by:
Hi, Is it possible to access Lotus notes using Python? Can anyone provide me some pointers? Thanks Sateesh
5
5022
by: NickBlooruk | last post by:
Hello, I have successfully linked a Lotus Notes server to our SQL Server database using an ODBC connection. This works fine when wanting to select records eg openquery(LOTUSNOTES2, 'select * from Person' ) The problem I have is when I try to update the record I get an error eg update openquery(LOTUSNOTES, 'select * from Person where
5
7396
by: Colin Anderson | last post by:
I discovered, with great excitement, this article http://www.davison.uk.net/vb2notes.asp when researching methods for emailing from Access via Notes. Unfortunatly, when I run this I get a Run-time error. When I run it on an XP machine it crashes, but on an NT box it just generates an unknown error, handled by the error handler. I have debugged and stepped through the code and have narrowed the issue to the point at which the...
0
5617
by: PZ Fosbeck | last post by:
I'm not a Lotus Notes developer but thanks to this group's archives have successfully created a function for sending Lotus Notes emails from Access. The follow code works great except I want to remove my name from the 'Sent By' portion of the email. These messages are sent using my client session of Lotus Notes, using a database called 'Tech Team' The resulting email message headers contains (Bold, the From name) 'Tech Team'
1
13052
by: Joe | last post by:
HI Has anyone been able to work with lotus notes automation classes??? Can you post sample code of how to use these classes. I have setup in VB but I am not able to port to C# This is what I have so far - I cannot create a session and not sure how to setup From/Subject
3
8278
by: =?Utf-8?B?SmFtZXNU?= | last post by:
I can create a message and send it via my btopenworld account but is the method the same when using Lotus Notes. I have no experience of Lotus Notes whatsoever. I have never seen it at all. the code I am using is: dim smtp as new smtpclient dim message as new mailmessage( from@cc.com, to@dd.com) message.subject = "test"
2
3978
by: MarkStorer | last post by:
Hi All I need to email a report (with contains graphs) via Lotus Notes. I've tried the 'SendObjectSnp' method (which works with some Lotus Notes clients (but not many others)); so I used the code below: - Public Sub SEND_EMAILS() Dim session As Object Dim db As Object Dim doc As Object Dim rtitem As Object
1
2784
by: KDawg44 | last post by:
Hi, We have a Lotus Notes Database that tracks time spent on projects. What I would like to do is develop a Time Tracker in Python that communicates with the server. This would pull projects in and allow a use to start a timer as he/she works on a given project. The user would then be able to commit this back to the database (thus, preventing them from having to go to the calendar view and pick the project and enter the hours).
0
1241
by: =?ISO-8859-1?Q?Michael_Str=F6der?= | last post by:
HI! Anybody here with experience in accessing Lotus Domino with Python via DIIOP? In particular I'd like to be able to register Notes users with a Python script. Preferrably without having to use Win32 COM although it would be better than nothing. Adding address Notes book entries via LDAP is possible but AFAIK does not lead to full Notes users (with mailbox and Notes-ID file).
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.