Place a email that has been sent to the Sent folder

Hello ladies and gentleman,

I need some help. I have written some code in Visual Basic for Applications (VBA) to send a email out, but I want the email to be placed in the Sent folder and to be unread. How do I get that? My code is below. I’m using late-binding:

Sub SendEmail()

Dim session As Object

Dim db As Object

Dim doc As Object

Dim rtitem As Object

Set session = CreateObject("Notes.NotesSession")

Set db = session.CurrentDatabase

Set doc = db.CreateDocument

doc.Form = "Memo"

doc.SendTo = "John Doe"

doc.Subject = "Here's the document you wanted"

doc.Body = "Here it is"

Set rtitem = doc.CreateRichTextItem("Attachment")

Call rtitem.EMBEDOBJECT(1454, "", "C:\Test.doc")

Call rtitem.ADDNEWLINE(1, True)

Call doc.Send(False)

End Sub

Subject: Place a email that has been sent to the Sent folder

There is a preferences setting that forces all documents to be saved to sent folder when mailed, users can set this property in the User Preferences setting.

Since you want the document to be saved, simply save the document before the send command, this will save a copy of the document to the db and the mail action will automatically set it up to show up in the Sent View.

Another approach is to set the fields as you have set then add a new field

doc.MailOptions = “1”

and save the document, this field will make notes send the document on save. Using this approach you must make sure that TO[, CopyTo, BCCTo] fields are populated correctly.

Let us know how it goes.

Subject: RE: Place a email that has been sent to the Sent folder

My settings are set up as you state with mail that is sent to keep a copy, but while doing this in VB/VBA, I never get the mail that was sent to go to the Sent view!!!

Subject: RE: Place a email that has been sent to the Sent folder

OK, I got it…I had to use doc.SaveMessageOnSend = True to get the message to go into the Sent View. DOH!

Although it remains as unread in the Sent View. A flaw in Notes?

Subject: RE: Place a email that has been sent to the Sent folder

No – if the doc has never been opened in the UI, it is unread by definition.

Subject: Place a email that has been sent to the Sent folder

You will need to call the function PutInfolder.

Subject: RE: Place a email that has been sent to the Sent folder

That creates a folder called Sent, which is not what I want to do.

I want the email to be in the Sent section, as if a user we’re typing a email manually and click the Send button and a email goes into the Sent section.