Copying incoming email messages to new Lotus Notes document

10 pts.
Tags:
Lotus Notes
LotusScript
I have an application which enables us to centrally file all incoming emails in a Notes database. An action has been created in the Mail Template which uses the CopyItemToDocument function to copy the body of the email message a new notesdocument in the said database. This as a rule works well copies all text and attachments (although does lose formatting). However on some incoming emails we get a NoteItem not found error message on the CopyItemToDocument. On checking these emails there are mulitple body fields. Can anybody shed some light or offer an alternative? Please forgive me I'm fairly new to Lotus Notes development. Thanks in advance. Code snippet below.
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesUIView
Dim ndc As NotesDocumentCollection
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Dim session As New Notessession
Dim itm3 As Variant
Dim Itm4 As Variant
Set db = session.CurrentDatabase
Set uidoc = workspace.currentdocument
'There is additional code not showing which gets cdoc
Dim cfdb As New notesdatabase(cdoc.CFServ(0),cdoc.CFDB(0))
dim edoc as notesdocument
set edoc = cfdb.createdocument
set doc = ws.currentdocument.document
set itm3 = doc.getfirstitem("Body")
set itm4 = itm3.copyitemtodocument(cfdoc,"Body")


Software/Hardware used:
IBM Notes 9.01
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

You should always test your objetc after initialisation to check if they are not Null.
So the programm will not stop. I would secure it like this

set itm3 = doc.getfirstitem("Body")
if not itm3 is Nothing then
  set itm4 = itm3.copyitemtodocument(cfdoc,"Body")
Else
print "Body copy error !"
end if

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: