Sending Lotus Notes Mail from Access - Bypassing Password Prompt

G

Guest

I would like to send e-mail from Access/VB via Lotus Notes. I have used the
code posted by rijhare and it works very well. However, it requires that I
enter my notes password. I have reviewed the questions posted by others and
it seems that some have avoided the password by including the line:

Session.Initialize ("Password")

Unfortunately that did not work for me and I can't understand why.

I played arround with interchanging Session =
CreateObject("Notes.NotesSession") and Session =
CreateObject("Notes.NotesSession") as some suggested but that didn't work
either.

If anyone has any suggestions I would be very appreciative.


Code:public Sub SendNotesMail(Subject As String, Attachment As String,
Recipient As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into Lotus Notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim Session

Set Session = CreateObject("Lotus.NotesSession") ' Using
LOTUS.NotesSession here

'The next line (when not commented out) doesn't circumvent the password
prompt
Session.Initialize ("Password")

UserName = Session

MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) -
InStr(1, UserName, " "))) & ".nsf"

Set Session = CreateObject("Notes.NotesSession") ' Using
NOTES.NotesSession here

'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText
Mail.Doc.Importance = "2"
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment,
"Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
MailDoc.SEND 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top