Manage Learn to apply best practices and optimize your operations.

Ms Access Makes Calls To The Lotus Notes Dll's Notes To Send Email

I had a situation where I am using MS Access to build individual files for each
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")

'Create a handle to lotus notes mail box using the session created above. Note
: 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 last published in November 2000

Dig Deeper on Domino Resources - Part 5

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...