3
« : 22 Декабрь 2010, 10:54:14 »
Ошибка: "БД уже содержит док-т с этим идентификатором UNID"
LNotes 7
Excel 2003
Возникает когда используется SAVEMESSAGEONSEND и вложение файла
Без вложения ошибка не возникает и письмо сохраняется в отправленных
Как исправить?
код процедуры
=============
Function Send_Mail(mailSendTo, mailCCTo, mailSubject, AttachFile)
Dim objNotesSession As Object
Dim objNotesMailFile As Object
Dim objNotesDocument As Object
Dim objNotesField As Object
On Error GoTo SendMailError
EMailBCCTo = M.Range("F34").Value '' Optional
''Establish Connection to Notes
Set objNotesSession = CreateObject("Notes.NotesSession")
''Establish Connection to Mail File
Set objNotesMailFile = objNotesSession.GETDATABASE("", "")
''Open Mail
objNotesMailFile.OPENMAIL
''Create New Memo
Set objNotesDocument = objNotesMailFile.CREATEDOCUMENT
Set objNotesField = objNotesDocument.AppendItemValue("Form", "Memo")
''Create 'Subject Field'
Set objNotesField = objNotesDocument.AppendItemValue("Subject", ">>: " & mailSubject)
''Create 'Send To' Field
Set objNotesField = objNotesDocument.AppendItemValue("SendTo", mailSendTo)
''Create 'Copy To' Field
Set objNotesField = objNotesDocument.AppendItemValue("CopyTo", mailCCTo)
''Create 'Blind Copy To' Field
Set objNotesField = objNotesDocument.AppendItemValue("BlindCopyTo", EMailBCCTo)
''Create 'Importance' Field (High)
Set objNotesField = objNotesDocument.AppendItemValue("Importance", "1")
''Create 'DeliveryPriority' Field (High)
'Set objNotesField = objNotesDocument.APPENDITEMVALUE("DeliveryPriority", "H")
''Create 'Body' of memo
Set objNotesField = objNotesDocument.CREATERICHTEXTITEM("Body")
With objNotesField
.APPENDTEXT M.Range("K28").Value
.ADDNEWLINE 1
.APPENDTEXT M.Range("K29").Value
.ADDNEWLINE 1
End With
''Attach the file --1454 indicate a file attachment
Set objNotesField = objNotesField.EMBEDOBJECT(1454, "", AttachFile)
''Send the e-mail
objNotesDocument.SAVEMESSAGEONSEND = True
objNotesDocument.Send (False)
''Release storage
Set objNotesField = Nothing
Set objNotesDocument = Nothing
Set objNotesMailFile = Nothing
Set objNotesSession = Nothing
''Set return code
Send_Mail = True
Exit Function
SendMailError:
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Send_Mail = False
End Function