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?

RoyRumaner
  • 769
  • 1
  • 9
  • 29
  • Any relation to this? http://stackoverflow.com/questions/9083135/lotus-notes-get-attachment-names-from-document – Simon O'Doherty May 15 '12 at 15:04
  • 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. – RoyRumaner May 15 '12 at 15:26
  • 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. – Richard Schwartz May 15 '12 at 19:26

2 Answers2

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.

bluish
  • 26,356
  • 27
  • 122
  • 180
Rob Darwin
  • 942
  • 1
  • 10
  • 17
  • 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. – RoyRumaner May 15 '12 at 16:07
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$)
Steve
  • 1