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...
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
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) Then Forall o In rtitem.EmbeddedObjects If ( o.Type = EMBED_ATTACHMENT ) Then 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:
- Tip: Extract attachments and indicate a new location
- Expert Advice: Extracting and reattaching attachments
- FAQ: LotusScript advice
- Reference Center: LotusScript tips and resources