开发者

lotus notes automation

Is it possible to automate lotus notes to post a local file to a database? I have a daily task to post a logfile to a notes database. I can gather the logfile via script but don't know enough about notes scripting to figure this out.

I know thrre is a com interface as long as I have the client on the PC, but I can't figure out how to get a file uploaded to a dataase. I can 开发者_Python百科use either vbscript or (preferred) powershell


If you search around the net you'll find examples of using VBScript to manipulate Lotus Notes. Here's one example: http://haveworld.blogspot.com/2006/10/vbscript-and-lotus-notes.html

You'll need to know a little about Lotus Notes to make this work, though. Start small and see if you can even get the Notes Version to appear:

Set oNotesSession = CreateObject("Notes.Notessession") 'create notes session
Msgbox oNotesSession.NotesVersion

If that works, you know you're in good shape. If not, make sure you've installed Lotus Notes correctly and configured it on the client.

The code to post a local file to a database involves connecting to Notes, creating a new Notes Document, adding a file object into the body of the document, and then saving it. You can use any kind of Notes Database to do this, but I'd suggest creating a new one based on the Document Library template, and using that to store your files.

Here is some code that will create a new Notes document, set the subject field, attach a file, and then save the document. This assumes there's a local Notes database already available called "FileStorage.nsf"

strFileName = "C:\Windows\Media\tada.wav"
strSubject = "Your Subject Goes Here"

Set oNotesSession = CreateObject("Notes.Notessession") 'create notes session
Set oDb = oNotesSession.GetDatabase("", "FileStorage.nsf") 'open database on local named FileStorage.nsf
Set oDoc = oDb.CreateDocument

' Filling the fields
oDoc.Subject = strSubject
Set oBody = oDoc.CreateRichTextItem("Body")
oBody.EmbedObject 1454, "", strFileName   '1454 = Embedded Attachment type

oDoc.Save False, False
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜