Hi Everyone,

I am currently having an issue with a procedure that sends email via Lotus Notes. I am using the codes below and, basically, the system crashes when the NotesSession is set to "nothing" for the third time in the same run (so when a third email is sent). The error I get is the common "Access has encountered an error and needs to close........".

It is pretty weird as the system is able to send the first two emails without any problem. My questions would be:

1) Has anyone ever encountered a similar issue?
2) Is there anything in the codes below that can be improved or written in a "better" way, without changing the functionality (basically, it needs to send emails without opening Lotus Notes or prompting the user).

Any help / suggestions would be very much appreciated! Many thanks!

Sub SendEmail()

Dim oNotes As New NotesSession
Dim oDB As Domino.NotesDatabase
Dim oMail As Domino.NotesDocument

oNotes.Initialize "secretPassword"
Set oDB = oNotes.GetDatabase("xxxxx", "xxxxxx")
Set oMail = oDB.CreateDocument

With oMail
.ReplaceItemValue "Subject", "My Subject"
.ReplaceItemValue "SendTo", "xxx.xxxx@yahoo.com"
.ReplaceItemValue "Body", "This is a Test"
.SaveMessageOnSend = True
.Send False, "xxx.xxxx@yahoo.com"
End With

Exit_SendEmail:
Set oMail = Nothing
Set oDB = Nothing
Set oNotes = Nothing

End Sub