SaveMessageOnSend randomly causes error. Any ideas why?

I am sending an email to my self using Notes API. The code looks like this:


Sub Main()

    Try

        Dim oNotesDoc As NotesDocument

        Dim strOrganizer As String = "CN=System Adminstrator/O=PMT"

        Dim oRTF As Object



        oNotesDoc = clsLotusFunctions.NamesDatabase.CreateDocument()



        With oNotesDoc

            clsLotusFunctions.GenerateLotusMemo(oNotesDoc)

            oRTF = .CreateRichTextItem("Body")

            oRTF.AppendText("Body")

            .ReplaceItemValue("Subject", "Subject")

            .ReplaceItemValue("Importance", "2")

            .ReplaceItemValue("From", strOrganizer)

            .ReplaceItemValue("AltFrom", strOrganizer)



            .ReplaceItemValue("SendTo", strOrganizer)

            .ReplaceItemValue("$StorageTo", "1")

            .ReplaceItemValue("InetSendTo", strOrganizer)



            .SaveMessageOnSend = True

            .Send(True)

            Console.WriteLine("Message Sent")

        End With



    Catch exc As Exception

        Console.WriteLine("Error: " + exc.ToString)

    End Try



    Console.Read()

Randomly message is not saved in “Sent” folder and an error message is thrown:

Database already contains a document with this ID (UNID)

The error appears only when sending message to the same user, as a sender.

Any ideas why does it happen and how situation like this could be avoided?

TIA

Edmundas

Subject: SaveMessageOnSend randomly causes error. Any ideas why?

No answers but I’ll contribute a few thought provoking questions.

What’s the environment for this? It looks like it is triggered by a UI event (button, form event)???

What does the “$StorageTo” field do? Usually $ fields have some restricted functionality (although you oftentimes can use them). Could the “$StorageTo” field be conflicting with or redundant with the “.SaveMessageOnSend” property?

Obviously I am not familiar with the Java side of things. HTH.