Repost - EmbedObject is changing the name of the file - no ideas?

This is my code snippet to cycle thru a list of potential filepaths that the user may choose to include as attachments in a LS generated email message:

If addedlist(0) <> “” Then

Forall y In addedlist

'check to see if this file was selected

pos = Arraygetindex(selections, y)

If Not(Isnull(pos)) Then

'this file was selected, so attach it to the mail msg

Set rtitemtemp = New NotesRichTextItem( doc, “TempBody” )

Set object = rtitemtemp.EmbedObject ( EMBED_OBJECT, “”, y )

If( object Is Nothing ) Then

Messagebox "Error creating attachment: " & y

Else

Call rtitem.AppendRTItem( rtitemtemp )

End If

End If

End Forall

End If

After this code runs, the current uidoc is printed in PDF format and appended as the last attachment. The email is sent fine if I do not select any additional files to include. However, if I select an additional file, the above code will add the file with the wrong file name. For example, I tried to attach c:\bobp\excel files\camping.xls I don’t receive an error, but in the debugger, it shows the embedded object Name in my rtitem as EXT64432.

Naturally, the email is not sent, and I suspect it’s because it cannot find the file EXT64432 when it tries to send the msg.

Why would LS rename the file when it embeds it? I don’t understand… what am I missing?

Thanks in advance for any advice…

(I also tried to attach a file where there were no spaces in the filepath and got the same result)

btw - this is the code to add the pdf file of the printed uidoc to the email. It always shows the correct filename in the rtitem in debugger:

'print the quote to the pdf printer

Call uidoc.Print(1)

Sleep (4) 'to make sure the pdf is finished printing

Set rtitemtemp = New NotesRichTextItem( doc, “TempBody” ) 'to clear its contents

filename = "c:\pdf995\output" & uidoc.WindowTitle & “.pdf”

Set object = rtitemtemp.EmbedObject ( EMBED_ATTACHMENT, “”, filename)

Call rtitem.AppendRTItem(rtitemtemp)

Subject: RE: Repost - EmbedObject is changing the name of the file - no ideas?

Don’t put it in one rich text item and then append that to another rich text item. Just put it where you want to begin with. Also, don’t use New NotesRichTextItem when there is already a rich text item by that name in the document.

If you’re still having a problem, you will have to show more code. Especially we need to see how all your variables are getting assigned and declared.

NotesRichTextItem.Update method might be a good thing to do after adding an object.

Subject: Thanks Andre… I found the problem

I was using EMBED_OBJECT instead of EMBED_ATTACHMENT as my parameter. UGH! (wasted too many hours on that one!)

My apologies…

I’m not sure where I picked up the method of first putting the attachment in another rtitem and then appending it. I took it out, though, and it works.

Thanks for your time and your response. Sometimes, I just need a fresh set of eyes to set me straight.