?
Solved

Open an attachment

Posted on 2004-08-29
7
Medium Priority
?
423 Views
Last Modified: 2013-12-18
I need to show to the user a group of files attached to a document from a view without the user have to open the document and have to make a a click over every item and press "Launch...".  Maybe somebody have a script to do that.

Thanks in advance
0
Comment
Question by:arcano232
7 Comments
 
LVL 15

Expert Comment

by:Bozzie4
ID: 11928870
Is this for the Notes Client, or for the web ?

Tom
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 11932091
You can display the attachment names in the view, that;s trivial.  The following button (action button in a view) will display the list of attachments as a picklist for the user to select from:

fileNameToLaunch := @Prompt([OKCancelList]; "Attachments"; "Select an attachment"; @AttachmentNames; @AttachmentNames);
@Prompt([OK]; "Your selection"; fileNameToLaunch)

The question is, how do you get the selected name to launch?  There is no built-in mechanism.  In other recent posts, I've sugegsted ways to detach files and launch via the OS, using script.  The gotchas are name conflicts and cleaning up the files later ... Notes takes care of both of these in its launch mechanism, you would have to do the same without the luxury of "system level" services.

The other problem you have is that you seem to want to launch multiple files at once.  I can tell you right now, that's usually a dumb idea.  To much screen activity and I/O at once, user would have trouble dealing with it.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11954768
I have a soln that work for single attachment.. I can change it to work with multiple.. But not sure if I want to give out the  code just for 125...

~Hemanth
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 31

Expert Comment

by:qwaletee
ID: 11957315
Hemantha, I've never know you to be a points hound!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11957354
Yes.. I am not hungry for points. But want to break the mentality that EE is cheap and can get away with it easily...It is like grading B and C even we dedicate time and effort for them...
0
 

Author Comment

by:arcano232
ID: 12000161
I increase the points. 250 is ok???
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 1000 total points
ID: 12000337
Here is the code...Create agent which will run on selected docs

Paste the code in appropriate sections of the agent

DECLARATIONS

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(Byval hwnd As Long, Byval lpszOp As String, _
Byval lpszFile As String, Byval lpszParams As String, _
Byval LpszDir As String, Byval FsShowCmd As Long) As Long

Declare Private Function GetDesktopWindow Lib "user32" () As Long

Private Const SW_HIDE = 0&

INITIALIZE

Sub Initialize    
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim col As NotesDocumentCollection
    Dim doc As NotesDocument    
    Set db = session.CurrentDatabase
    Set col = db.UnProcessedDocuments
    Set doc = col.GetFirstDocument
    While Not doc Is Nothing
        LaunchAttachment doc
        Set doc = col.GetNextDocument(doc)
    Wend
End Sub


Sub LaunchAttachment(doc As NotesDocument)
    Dim ws As New NotesUIWorkspace    
    Dim rtItem As NotesRichTextItem
    Dim emobj As NotesEmbeddedObject
    Dim Scr_hDC As Long
    Dim ret As Long
    Dim arr() As String
   
    Set rtItem = doc.GetFirstItem("Body")    
    temp = Environ$("Temp") & "\"
    If Not rtItem Is Nothing Then
        If Isempty(rtItem.EmbeddedObjects) Then
            Msgbox "No attachments found",16,""
            Exit Sub
        End If
        Print "Looping through the attachment objects"
        Forall o In rtItem.EmbeddedObjects
            Redim Preserve arr(count) As String
            arr(count) = o.Name
            count = count + 1
        End Forall
       
        If count > 0 Then
            filearr = ws.Prompt(PROMPT_OKCANCELLISTMULT,"TITLE","PROMPT", arr(0), arr)
            Stop            
            If Not Isempty(filearr) Then
                Forall file In filearr
                    file = ReplaceSubString( file , " " , "_" )
                    Set emobj = rtitem.GetEmbeddedObject(file)
                    Call emobj.ExtractFile( temp & file )
                    Scr_hDC = GetDesktopWindow()
                    Print "Launching file at location..." & temp & file
                    ret = shellExecute(Scr_hDC, "open",file ,Null ,temp ,1&)
                    If ret <= 32 Then
                        Msgbox "An error occured while printing!"
                    End If
                End Forall
            End If
           
        End If ' count
       
    End If
End Sub

Function ReplaceSubString(Byval target As String, Byval rfrom As String, Byval rto As String) As String
    Dim pos As Long, lastpos As Long
    pos = Instr(target, rfrom)
    lastpos = 1
    Do Until pos = 0
        strReplace = strReplace & Mid$(target, lastpos, pos-lastpos) & rto
        lastpos = pos + Len(rfrom)
        pos = Instr(lastpos, target, rfrom)
    Loop
    ReplaceSubString = strReplace & Mid$(target, lastpos)
End Function    


>>>>>> NOW.. you determine the worth of this code
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question