Domino Code Fragment

Code Name*
Auto-launching attachments in Win32
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.224.95.38
Description*
Launches an attachement.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

If you have ever tried to extract a file from a rich text field using the rtitem.ExtractFile method and then launch it using the LotusScript Shell command, you will know that you need to put the name of the proper executable (with it's path) as the first argument of the Shell command. This can be a problem for several reasons....the path for the executable is potentially different on each person's machine and you need to somehow identify the type of file so that you launch the proper program.

Here's a slick solution for you Windows 95/NT users: use the START.EXE as the program, passing the filename as the file to execute. Here is some sample code from an agent which launches the first attachment in the current mail document:

    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Set uidoc = ws.CurrentDocument
    Dim doc As NotesDocument
    Set doc = uidoc.Document
    Dim rtitem As Variant
    Set rtitem = doc.GetFirstItem( "Body" )
    Forall o In rtitem.EmbeddedObjects
         If ( o.Type = EMBED_ATTACHMENT )  Then
              Call o.ExtractFile ( "c:\temp\" & o.Source)
              resp% = Shell ("start.exe c:\temp\" &  o.Source)
              exit forall
         End If
    End Forall