• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

Open an attachment

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
arcano232
Asked:
arcano232
1 Solution
 
Bozzie4Commented:
Is this for the Notes Client, or for the web ?

Tom
0
 
qwaleteeCommented:
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
 
HemanthaKumarCommented:
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
qwaleteeCommented:
Hemantha, I've never know you to be a points hound!
0
 
HemanthaKumarCommented:
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
 
arcano232Author Commented:
I increase the points. 250 is ok???
0
 
HemanthaKumarCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now