VBA Macro - how to save sent mail in SENT view

Hello,

I have issue with my code and that is that mail is not saved in the “sent” view after I send it.

I am using lotus.notessession and here is the code:

Sub mailsendervar2(EmailRecipient As Variant, EmailSubject As String, pathToFile As String)

Dim Maildb As Object

Dim MailDoc As Object

Dim Body As Object

Dim Session As Object

'Start a session to notes

Set Session = CreateObject(“Lotus.NotesSession”)

'This line prompts for password of current ID noted in Notes.INI

'Call Session.Initialize

'or use below to supply password of the current ID

Call Session.Initialize(“MYPASSWORD”)

'Open the mail database in notes

Set Maildb = Session.GetDatabase(“”, “MYNSFFILE”)

If Not Maildb.IsOpen = True Then

    Call Maildb.Open

End If

'Create the mail document

Set MailDoc = Maildb.CreateDocument

Call MailDoc.ReplaceItemValue(“Form”, “Memo”)

'Set the recipient

Call MailDoc.ReplaceItemValue(“SendTo”, EmailRecipient)

'Set subject

Call MailDoc.ReplaceItemValue(“Subject”, EmailSubject)

'Create and set the Body content

Set Body = MailDoc.CreateRichTextItem(“Body”)

Call Body.AppendText(“”)

'Example to create an attachment (optional)

Call Body.AddNewLine(2)

Call Body.EmbedObject(1454, “”, pathToFile, “Attachment”)

'Example to save the message (optional)

MailDoc.SaveMessageOnSend = True

'Send the document

'Gets the mail to appear in the Sent items folder

Call MailDoc.ReplaceItemValue(“PostedDate”, Now())

Call MailDoc.Send(False)

'Clean Up

Set Maildb = Nothing

Set MailDoc = Nothing

Set Body = Nothing

Set Session = Nothing

End Sub

The mail is sent correctly, but I want to save it in the sent view as well.

Subject: I think you need to save your document, it’s not appearing in all documents either right?

Subject: RE: I think you need to save your document, it’s not appearing in all documents either right?

You are correct, it does not appear in all documents.

But the savemessageonsend is set to True

Subject: But I think you are doing this as a backend document so it doesn’t matter that you set that value

Save it and see if you get what you want.