Domino Code Fragment

Code Name*
Lotus Notes OLE Automation with MS Excel
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.217.208.72
Description*
This demo uses OLE automation to create Notes mail from within Microsoft Excel, sending cell values in the body of the mail message. This is a great and easy-to-write example of how to use the Notes client with MS Office products, using the best of both products. You can cut and paste this VBA code example into Excel.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Sub Button1_Click()
MsgBox "this is button on my spread sheet"
Dim s As Object
Dim db As Object
Dim doc As Object
's and db declared in general as object
Set s = CreateObject("Notes.Notessession") 'create notes session
Set db = s.getdatabase("", "") 'set db to database not yet named
Call db.openmail 'set database to default mail database
Mycell = Sheet1.Cells(1, 4)
Set doc = db.createdocument ' create a mail document
msg = "Mail has been sent: " & Date & " " & Time & Chr(10) & 'these 2 lines need...
"The value in Cell D1 [ " & Mycell & " ] is in the body of the message" '...to be put on one line
Call doc.replaceitemvalue("SendTo", s.UserName) 'Notes client's user name (for testing)
Call doc.replaceitemvalue("Subject", "Excel message")
Call doc.replaceitemvalue("Body", msg)
Call doc.Send(False) 'send the message 'send the message
MsgBox doc.getitemvalue("Subject")(0) & " has been sent"
Set s = Nothing ' close connection to free memory
End Sub

demo.xls