Zozo24
Zozo24

Reputation: 1

I tried to export mails from Lotus to excel tables, but it don't work like I expected

I'm a little be sutck in this thing. The problem is I would like to export my mails to an excel file, this part is work fine but if I want to change the (.nfs) file to another user Lotus Notes file and run this script bleow, I'll get my mails and not the other Lotus user mails. So it dosen't matter what I write in to the path, it's alwasy run and exported with my mails ! If I just leave the path empty or write in a fake path it goes again and worked fine but It should have got an error but it didn't !

Can you help me out ? I don't know why the script ignores outside what I write in the path.

The reason why I need this it's simply I need for the "to: NASATOYMARKET.com" part from the mails.

Public Sub exportNotesMail()

    Dim mailDb As Object, doc As Object, alldocs As Object, Session As Object
    Set Session = CreateObject("Notes.NotesSession")
    Set mailDb = Session.GETDATABASE("", **"C:\Users\username\Desktop\username.nsf"**) <-- This is what is ignored outside by the script.
    If mailDb.IsOpen = False Then mailDb.OPENMAIL
    Set alldocs = mailDb.AllDocuments
    Set doc = alldocs.GetFirstDocument

    While Not (doc Is Nothing)
        'If doc.GetItemValue("Form")(0) = "Memo" Then
                x = x + 1
                Sheet2.Cells(x, 1) = doc.Created
                Sheet2.Cells(x, 2) = doc.GetItemValue("Sendto")(0)
                Sheet2.Cells(x, 3) = doc.GetItemValue("Subject")(0)
                'End If
                'Else: MsgBox "Not match"
        'End If
        Set doc = alldocs.GetNextDocument(doc)
    Wend
End Sub

Upvotes: 0

Views: 287

Answers (3)

Zozo24
Zozo24

Reputation: 1

Thansk Knut ! Really much !

Now that's how it works:

Set mailDb = NSession.GetDatabase("", "C:\Users\user\Desktop\user_rep.nsf")
If mailDb.IsOpen = False Then Call mailDb.Open

Upvotes: 0

Andre Guirard
Andre Guirard

Reputation: 720

Following up on Ken's answer. It's not just that you have an OPENMAIL. It's that you're using OPENMAIL as your fallback instead of doing proper error handling, then you're doing something that always causes an error, which causes your fallback to take effect. You have to find out why the GETDATABASE call is unable to open the specified database. The way you've written it, you're trying to open a local file. Does the local file actually exist? Is it at the specified filepath? What happens if you try to open it in the client? The error message from making the attempt, will be instructive.

Upvotes: 0

Ken Pespisa
Ken Pespisa

Reputation: 22266

You have a call to OPENMAIL which will always open your personal mail file. Change that to just OPEN and it should work.

Upvotes: 1

Related Questions