I have a tiny problem with a VBA that I prepared to send emails from a database in lotus notes (other than the main database)
When I send the same email from the main database in lotus notes, (username database) I have no problems, it runs smoothly. However, the same coding, I just change the server and the database name, it sends the emails but with a message screen in lotus notes as "do you want to save your changes?" I need to select yes or no, then it sends the emails. As I said, the only difference is the database and the server in the coding.
Here is the message in Lotus Notes:
Here is the VBA code.
Sub SendWithLotus()
Dim NSession As Object
Dim NDatabase As Object
Dim NUIWorkSpace As Object
Dim NDoc As Object
Dim NUIdoc As Object
Set NSession = CreateObject("Notes.NotesSession")
Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
Set NDatabase = NSession.GETDATABASE("XXXXX/XXX/XXXServer", "mail\YYYYY")
'=> this is the main change, if I want to send from the main mail database, I don't enter anything inside the brackets and everyting works fine.
If Not NDatabase.IsOpen Then
NDatabase.OPENMAIL
End If
'Create a new document
Set NDoc = NDatabase.CREATEDOCUMENT
With NDoc
.SendTo = Range("O8").Value
.CopyTo = ""
.Subject = Range("O7").Value
'Email body text, including marker text which will be replaced by the Excel cells
.body = vbNewLine & vbNewLine & _
"**Cell Contents**" & vbNewLine & vbNewLine & _
""
.Save True, False
End With
'Edit the just-created document to copy and paste the Excel cells into it
Set NUIdoc = NUIWorkSpace.EDITDOCUMENT(True, NDoc)
With NUIdoc
'Find the marker text in the Body item
.GOTOFIELD ("Body")
.FINDSTRING "**Cell Contents**"
'.DESELECTALL 'Uncomment to leave the marker text in place (cells are inserted immediately before)
'Replace it with the Excel cells
Sheets("Sheet1").Range("A1:L58").CopyPicture xlScreen, xlBitmap
.Paste
Application.CutCopyMode = False
.Send
.Close
NDoc.SAVEMESSAGEONSEND = True
End With
Set NSession = Nothing
NDatabase = Nothing
NDoc = Nothing
End Sub
The reason might be settings of the different database or I might need to code to close that message box in Lotus Notes, but I don't know how.