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

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?
0
Jaziar
Asked:
Jaziar
  • 9
  • 7
1 Solution
 
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
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.

 
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
 
JaziarAuthor Commented:
Very Nice Work - Thanks
0
 
p_parthaCommented:
Thanks for the points

Partha
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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