I am using following to send mails from my access database.

But getting an error on following lines

Session.Initialize ()

MailServerName = Session.GetEnvironmentString("MailServer", True)

Set dbDirectory = Session.GetDBDirectory(MailServerName)

Username = Session.Username

Thanks in advance.


= = = code starts here = = =

Public Sub SendNotesMailCOMVersion()
Dim Subject As String, Attachment As String, Recipient As String, BodyText As String, SaveIt As Boolean

Dim Session As NotesSession
Dim dbDirectory As NotesDBDirectory
Dim MailDB As NotesDatabase
Dim MailServerName As String
Dim Username As String
Dim MailDoc As NotesDocument
Dim Body As NotesRichTextItem
Dim attachedFile As NotesEmbeddedObject

Set Session = CreateObject("Lotus.NotesSession")

Session.Initialize ()

'a login prompt will be presented if Notes is not running
MailServerName = Session.GetEnvironmentString("MailServer", True)

'gets MailServerName system variable from notes.ini
Set dbDirectory = Session.GetDBDirectory(MailServerName)

'uses server's NAB/Domino Directory to get mail file path
Username = Session.Username

Set MailDB = dbDirectory.OpenMailDatabase
Set MailDoc = MailDB.CreateDocument
Set Memo = MailDoc.ReplaceItemValue("Form", "Memo")
'Set Recipients = MailDoc.ReplaceItemValue("SendTo", Split(Recipient, ";"))
'Set Recipients = MailDoc.ReplaceItemValue("SendTo", Split(Me.txtTotalRecipients.Text, ";"))
Set Recipients = MailDoc.ReplaceItemValue("SendTo", Me.txtTotalRecipients.Text)
Subject = MailDoc.ReplaceItemValue("Subject", Me.cboActionNeeded.Text)
Set Body = MailDoc.CreateRichTextItem("Body")
Body.AppendText (Me.Note)
Body.AddNewLine (2)
MailDoc.SaveMessageOnSend = SaveIt

If Attachment <> "" Then
Set attachedFile = Body.EmbedObject(1454, "", Attachment, "Attachment")
End If

MailDoc.Send (0) 'False would be preferable; recipient is already set by SendTo item

Set MailDB = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing

MsgBox "Done"

End Sub