Tuesday, February 1, 2011

Send Lotus Notes emails using VBS

Here's a block of code to send a Lotus Notes email using VBS.
Set objNotes = CreateObject("Lotus.NotesSession")
Call objNotes.Initialize(strNotesPassword) 
Set Maildb = objNotes.GetDatabase("", strLotusNotesDatabase)
If Not Maildb.IsOpen = True Then
  Call Maildb.Open
End If
Set MailDoc = Maildb.CreateDocument
Call MailDoc.ReplaceItemValue("Form", "Memo")
Call MailDoc.ReplaceItemValue("SendTo", arrSendTo)
Call MailDoc.ReplaceItemValue("BlindCopyTo", arrBlindCopyTo)
Call MailDoc.ReplaceItemValue("Subject", strSubject)
Set Body = MailDoc.CreateRichTextItem("Body")
Call Body.AppendText(strBodyText)
Call Body.AddNewLine(2)
Call Body.EmbedObject(1454, "", c:\attachment.doc", "Attachment")
MailDoc.SaveMessageOnSend = True
Call MailDoc.ReplaceItemValue("PostedDate", Now())
Call MailDoc.Send(False)

No comments: