THis is a follow up to a question from last week for me. I have tried to get the code below working to take the attached doc in the "doc" field on a record and copy this over to a tracer email which is sent to the user. I have tried many edits on this one but cannot get the attachment to come over to the letter. It is probably some simple little edit needed, but if anyone sees what I am missing here it would be greatly appreciated. The field on the main doc that has the attachment is called doc and the fieldname on the letter that goes to the user is called doc_attached.
Dim ws As New notesuiworkspace
Dim session As New NotesSession
Set db = session.CurrentDatabase
extractpath = "c:\temp\"
On Error Resume Next
Set emaildoc = db.CreateDocument
emaildoc.Form = "exp_mgt_final_copy"
emaildoc.SendTo = doc.contact
emaildoc.Principal = "IDSalesMaterialSubmission"
emaildoc.Subject ="Submission # " + doc.sub_num(0) +" Approved - Please return Final product "
Set rtitema = doc.GetFirstItem( "doc" ) ' or specify whichever RTField you need.
If Not ( Isempty( rtitema.EmbeddedObjects) ) Then
Forall o In rtitema.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
' extract file attachment to temp area
Call o.ExtractFile( extractpath & o.source )
' embed in other doc
Set object = rtitemb.EmbedObject( EMBED_ATTACHMENT, "", extractpath & o.source)
Set rtitemb = New NotesRichTextItem(emaildoc, "doc_attached")
emaildoc.ld_num = doc.ld_num
' doc.status = "Final Copy Required"