Solved

Open an attachment

Posted on 2004-08-29
7
376 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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 250 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Creating a new theme in discussion8.ntf 6 158
Lotus notes error message 6 88
Lotus notes email code 2 113
Notes > Exchange calendar issues 5 56
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
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now