Problem solve Get help with specific problems with your technologies, process and projects.

LotusScript to extract and move attachments to a Lotus Notes mailbox or file folder

SearchDomino.com LotusScript expert Cregg Hardwick explains how to extract and email attachments to a Lotus Notes mailbox or file folder of your choice using LotusScript code.

I'm trying to find a script that will extract and email attachments to a folder of my choice. I'd also like it...

to print the name of the attachment in the email from which it was removed. Thank you.

I assume that you mean you want to email the attachments to a Lotus Notes mailbox of your choice, as putting them in a folder on the file system is a completely different issue. But, here is how to do both both:

To begin with, creating a directory is easy. LotusScript provides the MkDir command, which takes the pathname of the new folder as a parameter. If appropriate, use the Dir$ command to check to see if the directory (or files within it) already exists.

Now, to extract all attachments, just get a handle to the rich text document and use code similar to the following…

If Not Isempty(rtitem.embeddedObjects) 
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT )  
Call o.ExtractFile ( AttachmentDirectory+
"\"+o.name )
End If
End Forall

The test to see if the object is an embedded attachment must be done. Otherwise, the code would trip over any files embedded as OLE objects (which cannot be detached).

Keep in mind that if you have an old pre-R5 Lotus Notes database, attachments may be stored in the documents object collection, instead of those for the rich text field. In theory, the same concepts apply; you just cannot pick a particular rich-text field to extract from. (See the Designer Help for more detail, if needed.)

Do you have comments on this Ask the Expert Q&A? Let us know.

Related information from SearchDomino.com:

Dig Deeper on Lotus Notes Domino Mailbox Management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.



  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...