I am using a Word Template Macro-Enabled document (.dotm) in which the user completes the form, then clicks the Command Button which saves the file, then send a lotus note to a specified address. The code for the saving works great, then I call the email function, and errors at the line to send the document.
The error is:
Run-time Error '-2147217504 (80040fa0)':
Notes Error: Database already contains a document with this ID (UNID).
Below is the code form the Email Function:
Public Function SendEmail(strName As String, strFile As String, strPOLICY)
Dim oDir As Domino.NotesDbDirectory
Dim oDBase As Domino.NotesDatabase
Dim oDoc As Domino.NotesDocument
Dim oRTItem As Domino.NotesRichTextItem
Dim oRTStyle As Domino.NotesRichTextStyle
Dim oRTTab As Domino.NotesRichTextTab
Dim oItem As Domino.NotesForm
Dim strMailServer As String, strImportance As String
Dim strTo() As String
'Dim strCC() As String
Set oSession = New Domino.NotesSession
Call oSession.Initialize(MyLnotesPassword)
ReDim astrTo(0)
astrTo(0) = strName
'astrCC(0) = strCarbon
strMailServer = oSession.GetEnvironmentString("MailServer", True)
Set oDir = oSession.GetDbDirectory(strMailServer)
Set oDBase = oDir.OpenMailDatabase
If oDBase.IsOpen Then
Set oDoc = oDBase.CreateDocument
strImportance = "0"
Call oDoc.ReplaceItemValue("Importance", strImportance)
Call oDoc.ReplaceItemValue("Form", "Memo")
'To: (for multi-recipient, use an array)
Call oDoc.ReplaceItemValue("SendTo", astrTo)
'Call oDoc.ReplaceItemValue("CopyTo", strCarbon)
'Call oDoc.ReplaceItemValue("BlindCopyTo", strBCC)
Call oDoc.ReplaceItemValue("DisplayReply", " ")
Call oDoc.ReplaceItemValue("tmpDisplayReplyInfo", " ")
' *** Update here (Subject line of the e-mail)
Call oDoc.ReplaceItemValue("Subject", strPOLICY)
Set oRTStyle = oSession.CreateRichTextStyle
Set oRTItem = oDoc.CreateRichTextItem("Body")
oRTStyle.FontSize = 11
oRTStyle.Underline = 0
' *** Update here (E-mail body updated by MAMONEC on July 8, 2008)
oRTStyle.NotesColor = COLOR_BLACK
Call oRTItem.AppendStyle(oRTStyle)
oRTStyle.Bold = 0
Call oRTItem.AppendStyle(oRTStyle)
Call oRTItem.AppendText("Attached is the affirmation for " & strPOLICY & ".")
'Call oRTItem.AddNewLine(2)
'Call oRTItem.AppendText("")
'Call oRTItem.AddNewLine(2)
oRTStyle.Bold = 1
oRTStyle.NotesColor = COLOR_BLACK
Call oRTItem.AppendStyle(oRTStyle)
' Attach agent list in e-mail
Call oRTItem.AddNewLine(2)
Call oRTItem.EmbedObject(1454, "", strFile)
UNID = oDoc.UniversalID
oDoc.SaveMessageOnSend = True
Call oDoc.Send(False) <----------------------Debugs here.
If Err.Number = Trim("0") Then
FullNotify = True
Else
FullNotify = False
End If
Else
End If
End Function
The email still gets sent, but I need this error to go away. I captured the UNID on two separate runs, and they were different??? Help!
