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 first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.