person listed in a database. Each file is custom built for the individual with
only data specific to the indvidual sales person. I needed to send the file to
the sales force via e-mail. So, in a table I listed some details about the
individual, like, Their e-mail address and where their file is located. For
each person in the table, I call the function listed below so that I could used
in MS Access to send e-mail. This code uses Lotus Notes Objects to send e-mail
from a MS Access Database.
On thing to note, in order to get this to work without any user intervention, I
created a notes ID that did not require a password. That way when MS Access
makes calls to the lotus notes DLL's it does not ask for the password.
I know this is not a lotusscript program , but I think it is too cool. It
really helped me to automate a process very nicely.
Well here is the code I hope you enjoy it.
Public Sub Send_Emails(EMailAddress As String, MailSubject As String,
FileLocation As String)
'This sub will be called for each person in the e-mail table.
Dim Session As Object
Dim db As Object
Dim agent As Object
Dim MailDoc As Object
Dim RTItem As Variant
'Create the session. This will cause Lotus notes to open in the background.
Set Session = CreateObject("Notes.NotesSession")
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
: The ServerName is the name of your server and the MailFile name is the file
name of the mail file that you want to use.
Set db = Session.GetDatabase("ServerName", "mail\MailFile.nsf")
'Create a new document
Set MailDoc = db.CreateDocument()
'Create a Rich Text item on the document.
Set RTItem = MailDoc.CreateRichTextItem("Body")
'Set some of the fields on the document.
MailDoc.Form = "Memo"
MailDoc.SendTo = EMailAddress
MailDoc.subject = MailSubject
'Append some text to the rich text field.
Call RTItem.AppendText("For the people using Lotus Notes, Double click on the
attachment below and select Launch.")
'Add 2 line.
Call RTItem.AddNewLine(2)
'Append some more text
Call RTItem.AppendText("All Other people need to find out where the file was
stored when you received this e-mail. Once you find the file, run it by double
clicking on it.")
'Add a few more lines.
Call RTItem.AddNewLine(2)
' Append a little more text
Call RTItem.AppendText("Once you launch or run the file, a WinZip window will
display. Click on the button labeled Unzip. When the blue bar at the bottom
of the window fills up and goes away, click on close. When you click on close
the WinZip box will go away.")
' Add some more lines.
Call RTItem.AddNewLine(2)
' Attach the file in the location passed into this function.
Call RTItem.EmbedObject(1454, "", FileLocation)
' Send the document.
MailDoc.Send (False)
End Sub
This was first published in November 2000