Finding All the attachments in a database

What is the best way to find out what attachments are in a database?

Here is what I need.  I want to be able to either look at a view or run a agent that will list me all the attachements in the database?  It would be nice if I could tell the attachement type (xls, doc, etc).

Is this possible?
JaziarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

p_parthaCommented:
you have to use db.alldocuments. This method will return you all the documents in the database. Using hte document collection returned, just check for Availability of $FILE.

let me know if u need code

partha
0
JaziarAuthor Commented:
Partha I always need the code.  Thanks for the prompt response
0
p_parthaCommented:
Sub Click(Source As Button)
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim doc As NotesDocument
      Set db = session.CurrentDatabase
      Set collection = db.AllDocuments
      Set doc = collection.GetFirstDocument()
      While Not(doc Is Nothing)  
            If doc.Hasitem("$file")  Then
                  attname = Evaluate(|@attachmentnames|,doc)
                  Forall x In attname
                        Msgbox x
                  End Forall
                  
                  
            End If
            Set doc = collection.GetNextDocument(doc)
      Wend
End Sub
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

JaziarAuthor Commented:
Partha -- tihs is a button on a view?  Where do I place the code?  Form? - View?
0
p_parthaCommented:
button in a form

partha
0
p_parthaCommented:
anywhere jaziar (form or view ) but place it in a button

partha
0
p_parthaCommented:
Did it work jaziar?

partha
0
JaziarAuthor Commented:
Partha - yes it works and I will be glad to increase the points if you can find a way to write all the results in to a view of a file - a XLS file would be great!!.  Right now you have to hit ok after everyone one found and in one database that can be 100's of attachements.   Can we make it where the results export out to a excel file?  As stated I will be glad to increase the points this is very important to me.  Thanks
0
p_parthaCommented:
check whether this is fine.. don't worry about points

Sub Click(Source As Button)
    Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim collection As NotesDocumentCollection
    Dim doc As NotesDocument
    Set db = session.CurrentDatabase
Dim fileNum As Integer
Dim fileName As String
Dim firstCheck As String
fileNum% = FreeFile()
fileName$ = "C:\jaziar.xls"

    Set collection = db.AllDocuments
    Set doc = collection.GetFirstDocument()
Open fileName$ For Output As fileNum%
    While Not(doc Is Nothing)  
         If doc.Hasitem("$file")  Then
              attname = Evaluate(|@attachmentnames|,doc)
              Forall x In attname
             Write #fileNum%, x
              End Forall
             
               
         End If
         Set doc = collection.GetNextDocument(doc)
     Wend
Close fileNum%

End Sub
0
JaziarAuthor Commented:
Partha That works great!!! I am very pleased.  But I do have one more question???  Is there a way that when this writes out to the file, it somehows links the attachements to the database location.  Example

jaziar.xls

one.jpg
two.doc
three.jpg

Lets say I click on the two.doc - is there a way it can know the location of the doc and open the doc from the spreadsheet.  I have to check a lot of the attachements and it is nice to have them in a list, but would be great if I can check them from the spreadsheet.  I am going to increase the points whether or not we can do this.  Your help has been appreciated.
0
JaziarAuthor Commented:
Point Increase!!!!!!!!!!
0
p_parthaCommented:
As far as i know, you cannot put the doclink in the excel sheet. But u can do something like this:

Sub Click(Source As Button)
   Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Set db = session.CurrentDatabase
Dim fileNum As Integer
Dim fileName As String
Dim firstCheck As String
fileNum% = FreeFile()
fileName$ = "C:\jaziar.xls"

   Set collection = db.AllDocuments
   Set doc = collection.GetFirstDocument()
GetDBServerPath =       "http://" + servername.common + "/" + db.FilePath +"/0/"
Open fileName$ For Output As fileNum%
   While Not(doc Is Nothing)  

        If doc.Hasitem("$file")  Then
             attname = Evaluate(|@attachmentnames|,doc)
             Forall x In attname
            Write #fileNum%, x +" Path = " + Getdbserverpath + doc.UniversalID +"?opendocument"
             End Forall
             
             
         End If
        Set doc = collection.GetNextDocument(doc)
     Wend
Close fileNum%

End Sub

0
ArunkumarCommented:
Partha....

After you win these points I have something more to offer you in the following url..

http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21150149.html

;-)
0
JaziarAuthor Commented:
Getting Variant Does Not Contain a Object
0
p_parthaCommented:
Sorry missed one line:

Sub Click(Source As Button)
   Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Set db = session.CurrentDatabase
Dim fileNum As Integer
Dim fileName As String
Dim firstCheck As String
fileNum% = FreeFile()
fileName$ = "C:\jaziar.xls"
      Dim servername As New notesname(db.server)
   Set collection = db.AllDocuments
   Set doc = collection.GetFirstDocument()
GetDBServerPath =      "http://" + servername.common + "/" + db.FilePath +"/0/"
Open fileName$ For Output As fileNum%
   While Not(doc Is Nothing)  

        If doc.Hasitem("$file")  Then
             attname = Evaluate(|@attachmentnames|,doc)
             Forall x In attname
            Write #fileNum%, x +" Path = " + Getdbserverpath + doc.UniversalID +"?opendocument"
             End Forall
             
             
         End If
        Set doc = collection.GetNextDocument(doc)
     Wend
Close fileNum%

End Sub

Arun:
I will look at it, but am still working in R5 only.

Partha
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaziarAuthor Commented:
Very Nice Work - Thanks
0
p_parthaCommented:
Thanks for the points

Partha
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

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.