Get attachment from notes mail and transfer notes document

Dear all, Does anyone know how to get the attachment in notes mail and copy it into notes document. I noticed that the attachment is in the field named “$File”, and I tried to get the attachment and copy it into notes document using the method below, but this doesn’t work.

  Dim itemA As NotesItem

  itemA=docCurrent.getfirstitem("$File")

  Call newdoc.Copyitem(ItemA, "Body")

So, can anyone pls give some advice on this problem ?

Thanks in advance.

Subject: Get attachment from notes mail and transfer notes document

Did you check the form? I answer a question similar to this earlier. The subject topic was “Saving Attachments to the local drive”.

The concept is the same except you are going to attach it to another notes document.

My example shows how to get the attachment (embeddedObject).

Here is the URL:

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/8783bcfe0021f32985256d6c003e1d3b?OpenDocument

HTH – Cheers

Subject: RE: Get attachment from notes mail and transfer notes document

Dear Joe Nelson,

  I have tried the script that u posted to me, but it occurs "Type Mismatch" problem on this line :

 	"Forall o In rtitem.EmbeddedObjects"

  

  Below is my full script (in a button), can you please check what caused the problem to occur? I have tried to define the rtitem to NotesRichTextItem also doesn't solve the problem.



  Thanks in advance.



    Dim ws As New NotesUIWorkspace

Dim ss As New NotesSession

Dim db As NotesDatabase

Dim uidoc As NotesUIDocument

Dim docCurrent, memo As NotesDocument

Dim rtitem As Variant

Dim object2 As NotesEmbeddedObject

Set db=ss.CurrentDatabase

Svr$=db.Server

Dim docDialog As New NotesDocument(db)

Set fdb=ss.Getdatabase(Svr$, "Notes Application\PCSPFS.nsf")

Set uidoc=ws.CurrentDocument

Set docCurrent=uidoc.Document

Call ws.DialogBox("Dialog Box for Mail Transfer", True, True, False, False, False, False, "Project Info", docDialog)

docCurrent.Jobname=docDialog.Jobname(0)

Set memo=fdb.CreateDocument

memo.Form="Memo"



Set rtitem=docCurrent.getfirstitem("Body")

If (rtitem.Type=RICHTEXT) Then

  Forall o In rtitem.EmbeddedObjects

   If (o.Type=EMBED_ATTACHMENT) Then

     Call o.ExtractFile("c:\My Documents\" & o.Source)

   End If

   Set rtitem2= New NotesRichTextItem( memo, "Body" )

   Set object2=rtitem2.EmbedObject(EMBED_ATTACHMENT, "", "c:\My Documents\" & o.Source)

End Forall

  End If



Call memo.replaceitemvalue("Jobname", docCurrent.Jobname(0))

Call memo.Save(True, False)