Need to work with $FILE attachments and I cannot access them
Asked Answered
P

2

7

I have an incoming email (mail-in db) that contains a RichTextField where "some" attachments are found. I am also finding attachments not in the RTF but in the Document as $FILE. I am trying to get a handle on all the objects to copy them to another outgoing email. I can find the $FILE using the code below.

 Dim rtiObject as NotesEmbeddedObject
 Dim rti_Email as NotesRichTextItem
 Dim obj_Email as NotesEmbeddedObject
 ForAll p in mailDoc.items
   if p.Name = "$FILE" then
     set obj_Email = mailDoc.GetAttachment(p.Values(0)) 'this will return the Name of the attachment (or file)
     set rtiObject = rti_Email.EmbedObject( EMBED_ATTACHMENT, "", obj_Email.Name) 'this is supposed to attach the file to the document's RTF
   End If
 End ForAll

When this script runs it finds the $FILE files and returns the name but not the object and I cannot do anything with it from there.

What do I need to do to get the attachment/object ($FILE) from the original doc and attach it to an RTF in the outgoing email?

I thought about detaching the attachment to the network and then attaching it to the outgoing email and then deleting the attachment from the network but that seems impractical.

Is there a better way to handle these $FILE type of attachments on the incoming email that would make this easier?

Palestine answered 15/5, 2012 at 14:52 Comment(3)
Any relation to this? #9083635Protect
Similar but not the same. It does explain why I cannot access the attachment when it is a $FILE but I want to know if anyone has figured out a way to make it work without changing the INI. That change would affect every application on the server and that is not an option at this point.Palestine
Do you have NotesSession.convertMIME = true or false in your code? If it is false, then inline MIME attachments may not be represented in $File items and you would have to write code to walk the MIME tree in order to access them.Insist
B
3

Try the EmbeddedObjects property of the NotesDocument object. Something like this:

Forall obj_Email in MailDoc.EmbeddedObjects
  If obj_Email.Type = EMBED_ATTACHMENT then
    Call obj_Email.Extract(sometempdirectory$ & obj_Email.Name)
    Call rti_Email.EmbedObject(EMBED_ATTACHMENT, "", sometempdirectory$ & obj_Email.Name)
End Forall

You can also do it without detaching if you wish.

Balm answered 15/5, 2012 at 15:36 Comment(1)
I don't want to detach and then have to delete the attachments so that is not an option. However, the link does point to a very nice possible solution and I am going to try that out.Palestine
R
0

You can access the $File field by preceding it with a ~.

filename$ = mailDoc.~$File(0)
Set fileObj = mailDoc.GetAttachment(filename$)
Call fileObj.ExtractFile(filename$)
Retractor answered 10/2, 2017 at 20:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.