Results 1 to 8 of 8

Thread: Export Lotus Notes View with specific folders to .csv

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    3

    Export Lotus Notes View with specific folders to .csv

    Hello,
    i have found the following LotusScript Code wich exports LotusNotesView to .csv datasheet. The code works fine.

    The problem is that when i start the Agent i need to be manualy on the folder that i want to export and it dosent work with the inbox.
    How can i change the script that it export the folders that i need ? I need two of them: Inbox, and a Folder called "Workflow".

    Code:
    Sub Initialize
    	Dim ws As New NotesUIWorkspace
    	Dim uiview As NotesUIView
    	Dim view As NotesView
    	
    	' use the workspace to get the current view
    	Set uiview = ws.CurrentView
    	Set view = uiview.View     
    	
    	Dim filenames As Variant
    	
    	'Dim cn As Variant	
    	
    	' Get filename from user using the current ViewName as the default file name
    	filenames = ws.SaveFileDialog( _
    	False,"File name",, "c:\", uiview.ViewName & ".csv")
    	If Not(IsEmpty(filenames)) Then
    		Call ViewCSVPrint (view, filenames(0) )
    	End If
    	
    	
    End Sub
    
    
    Sub  ViewCSVPrint (view As NotesView, FileName As String )
    	
    	Dim fileNum As Integer 
    	Dim entry As NotesViewEntry	
    	Dim vc As NotesViewEntryCollection
    	Dim rowstring As String	
    	Dim cns As String
    	
    	fileNum% = FreeFile()
    	Open filename For Output As fileNum%
    	
    	' use the view column titles as the CSV headers
    	ForAll c In view.Columns
    		If cns = "" Then	
    			cns = c.title
    		Else
    			cns = cns + +","  + c.title 		
    		End If
    	End ForAll		
    	Print #fileNum%, cns
    	
    	
    	' now get and print the values for each row and column
    	Set vc = view.AllEntries
    	Set entry = vc.GetFirstEntry()
    	While Not entry Is Nothing 
    		rowstring = ""
    		ForAll colval In entry.ColumnValues
    			If rowstring = "" Then
    				rowstring = colval
    			Else
    				rowstring = rowstring + +","  + colval
    			End If			
    		End ForAll
    		Print #fileNum%, rowstring
    		Set entry = vc.GetNextEntry(entry)
    	Wend
    	Close fileNum%
    	
    	
    End Sub

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,905

    Re: Export Lotus Notes View with specific folders to .csv

    I assume it has something to do with the following lines:
    Code:
    	' use the workspace to get the current view
    	Set uiview = ws.CurrentView
    	Set view = uiview.View

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    3

    Re: Export Lotus Notes View with specific folders to .csv

    i changed the code to the following:
    Code:
    Sub Initialize
    	Dim session As New NotesSession  
    	Dim db As NotesDatabase
    	Set db = New NotesDatabase( "test", "plan.nsf" )
    	Dim view As NotesView
    
    	
    	' getview folder
    	Set view = db.GetView( "test" )   
    	
    	Dim filenames As Variant
    		
    	'Dim cn As Variant	
    	
    	' Get filename from user using the current ViewName as the default file name
    	filenames = ws.SaveFileDialog( _
    	False,"File name",, "c:\", uiview.ViewName & ".csv")
    	If Not(IsEmpty(filenames)) Then
    		Call ViewCSVPrint (view, filenames(0) )
    	End If	
    	
    End Sub
    Is this right ? Now the filename wont work anymore. Is there an alternative that set the databse name to default file name ?

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,905

    Re: Export Lotus Notes View with specific folders to .csv

    I don't have a clue, you really need to browse the IBM website support pages for this.
    https://www.ibm.com/support/knowledg...S_CLASSES.html

  5. #5
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: Export Lotus Notes View with specific folders to .csv

    Hi Micha,

    i haven't used Lotus in a long time, I did find this ..
    I probably have more stuff on my other PC

    Code:
    Public Sub ReadNotesInbox()
        Dim Session As Object
        Dim UserName As String
        Dim MailDbName As String
        Dim Maildb As Object
        Dim View As Object
        Dim x As Long
        Dim Doc As Object
        Dim FileName() As String
        Dim Item As Variant
        
        Set Session = CreateObject("Notes.NotesSession")
        UserName = Session.UserName
        MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) _
            - InStr(1, UserName, " "))) & ".nsf"
    
        Set Maildb = Session.GETDATABASE("", MailDbName)
        Maildb.OPENMAIL
        Set View = Maildb.getview("($Inbox)")
        For x = 1 To View.allentries.Count
            Set Doc = View.getnthdocument(x)
            Debug.Print String(20, "-")
            Debug.Print "From:" & Doc.getitemvalue("From")(0)
            Debug.Print "Subject:" & Doc.getitemvalue("Subject")(0)
            If Doc.Hasitem("$File") Then
                For Each Item In Doc.items
                    If Item.Name = "$FILE" Then
                        FileName = Item.Values
                        Debug.Print "Attachment:"; FileName(0)
                    End If
                Next
            End If
        Next
    End Sub
    I cant test it so,
    good luck

    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    3

    Re: Export Lotus Notes View with specific folders to .csv

    Hi Chris,
    first thanks for your help!

    Code isnt working. It says: Unexpected: item; Expected: =
    On this line:
    Code:
    For Each item In doc.items

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,905

    Re: Export Lotus Notes View with specific folders to .csv

    I would try one the IBM forums, this is not specific VB6, but has more to do with Notes automation.

  8. #8
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: Export Lotus Notes View with specific folders to .csv

    Quote Originally Posted by Micha_eight View Post
    Hi Chris,
    first thanks for your help!

    Code isnt working. It says: Unexpected: item; Expected: =
    On this line:
    Code:
    For Each item In doc.items
    Hi Micha,

    sorry I can't help any further as I don't have Lotus anymore, take the advice from Arnount
    and try a IBM-Forum

    sorry and regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width