Lotus Notes und Python ????

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
Gast

Donnerstag 17. März 2005, 15:36

Hallo zusammen,

ich habe ein Tool mit Access realisiert, das Mails in Lotus Notes verschickt. (kein Spam :D ).

Nun, würde ich gerne dieses Tool in WxPython realisieren.

Hat jemand einen Schimmer, wie das gehen könnte? Ich hab in Access einen OLE Aufruf programmiert.

Gruss domiii
Leonidas
Administrator
Beiträge: 16024
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Donnerstag 17. März 2005, 16:36

Du brauchst pywin32/win32all.
Damit kannst du COM Aufrufe machen und den VBA Code fast 1:1 übersetzen.
My god, it's full of CARs! | Leonidasvoice vs Modvoice
Gast

Freitag 18. März 2005, 16:13

Ich liebe das Internet und seine Codesnippets:

Code: Alles auswählen

## A simple hack to send Lotus Notes email from Python
## Tested using Python 2.1 on Windows 2000 with Notes 4.66c 
## by Brian Dorsey (updated 8/8/2001)
## brian@dorseys.org
##
## This is a barebones, simple way to send email with an arbitrary number of attachments.
## I experimented until it worked and then stopped. This is probably not the most 
## efficient way to do this (and I'm a newbie to Python as well!). If you have 
## any ideas, please send them my way!
##
## I'm not sure how well this may or may not work for anyone else, but it's 
## been working for me for a few months.
##
## This will send email from the currently active Notes account, and ask you for a 
## password if you're not logged in - so, it would probably need some kind of 
## modification to be used unattended on a server somewhere... 
##
## If you want to extend this, you can find more documentation on the Notes COM API
## at http://www.lotus.com/developers/devbase.nsf/homedata/homecom 
## a windows help version can be had by following the "Download Now" link on that 
## page and scrolling to the bottom of the page.
## (There may be better stuff out there, this is just the first thing I found. ;)
##
##
## Sample interactive test session: 
## Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
## Type "copyright", "credits" or "license" for more information.
## >>> import notesmail
## >>> notesmail.sendEmail(subject='Hello from Python!', body='Test message')
## >>> #Check your email, you should have a new message!
## ...
## >>> notesmail.sendEmail(subject='Hello from Python!', body='Test message', attac
## hments=['c:/Python21/README.txt']) #choose a file which exists on your system...:)
## >>> #Check it again, you should have a new email with the file attached!
## 

def sendEmail(recipients=[], subject='', body='', attachments=[]):
	"""Use Notes to send an email from the current user
	
	recipients -- a list of email addresses to send to 
		(or full names from the notes address book)
	subject -- a string containing the subject of the email
	body -- a string containing the body text of the email 
		(empty lines didn't seem to come through properly for me, I had to 
		include at least a space on each line to keep them from disappearing.)
	attachments -- a list of full path and filenames to attach to the email"""
	
	import win32com.client
	sess=win32com.client.Dispatch("Notes.NotesSession")
	db = sess.getdatabase('','')
	db.openmail
	doc=db.createdocument
	
	#Set the recipient to the current user as a default
	if not recipients:
		recipients = sess.UserName  
		
	doc.SendTo = recipients
	doc.Subject = subject
	doc.Body = body
	
	#Notes attachments get made in RichText items...
	if attachments:
		rt = doc.createrichtextitem('Attachment')
		for file in attachments:
			rt.embedobject(1454,'',file)
	doc.Send(0)
	
	
if __name__ == '__main__':
	#Send a simple test email to the current Notes user
	#sendEmail()
	sendEmail(subject='Test email from Python!', body='This has been a test, and only a test.')	
gruss domiii
Leonidas
Administrator
Beiträge: 16024
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Freitag 18. März 2005, 19:50

Das ist aber seltsamer Code:

Code: Alles auswählen

    db.openmail
    doc=db.createdocument
   
    #Notes attachments get made in RichText items...
    if attachments:
        rt = doc.createrichtextitem('Attachment')
        for file in attachments:
            rt.embedobject(1454,'',file) 
openmail ist doch einfach entweder eine Variable oder ein Callable und wird weder aufgerufen noch gesetzt. attachments dagegen fehlt völlig.
My god, it's full of CARs! | Leonidasvoice vs Modvoice
BlackJack

Sonntag 20. März 2005, 00:48

`attachements` ist ein Parameter der Funktion. Aber bei der zweiten Zeile von Code, den Du zitiert hast, fehlen wohl auch Klammern.
Leonidas
Administrator
Beiträge: 16024
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Sonntag 20. März 2005, 01:29

BlackJack hat geschrieben:`attachements` ist ein Parameter der Funktion.
Hups, hab ich übersehen.
Also, zwei mal fehlende Klammern :roll:
My god, it's full of CARs! | Leonidasvoice vs Modvoice
Antworten