Solved

VB 6 / Lotus 5.0.1 / View Inbox:

Posted on 2003-11-06
32
1,809 Views
Last Modified: 2007-11-27
I'm using:
-  VB6
- Lotus 5.0.1

FIRST:  I know how to create mail using VB6 for Lotus.

Now I want to view my inbox.   I found an example here, but I do not think my version is compatible. The example I followed was posted by Tim Cottee.

When I try and set my NotesView

Set vwInbox = dbNotes.GetView("$Inbox")
OR
Set vwInbox = dbNotes.GetView("Inbox")

My vwInbox is still nothing.
My dbNotes is the same that I use for creating emails.

The difference is when I wrote my emailing application I declared objects rather than
Notessession and NotesDatabase.

I use the CreateObject to set my session variable and I use my GetDatabase to set my db variable.   I shortened the program because it was in a loop to see if I could retreive just ONE inbox email.  Nothing!!!

CODE FOLLOWS!



--------------------------------------------------------------------
Declarations --------------------------------------------------------------------
--------------------------------------------------------------------
Option Explicit

Public doc As Object, rtobject As Object, oB As Object
Public session As Object

Public db As Object
Public dbNotes As Object
Public rtitem As Object
Public wkWKDay As Date
Public wkDayTime As Date
Public blnSentM, blnSentE As Boolean
Public blnSetM, blnSetE As Boolean
Public blnClear As Boolean

Public intRandom As Integer

Public fs As Object

Public user As String, server As String, mailfile As String

Public blnSwitch As Boolean

Public vwInbox As NotesView
Public vwEntry As NotesViewEntry
Public vwNav As NotesViewNavigator

Public docMessage As NotesDocument

--------------------------------------------------------------------
Setup Code --------------------------------------------------------------------
--------------------------------------------------------------------

    Set session = CreateObject("notes.notessession")
    user = session.UserName
    server = session.GetEnvironmentString("MailServer", True)
    mailfile = session.GetEnvironmentString("MailFile", True)
       
    Set db = session.GetDatabase(server, mailfile)
   
    Set vwInbox = db.GetView("Inbox")          '  db.GetView("$Inbox")
    Set vwNav = vwInbox.CreateViewNav
    Set vwEntry = vwNav.GetFirstDocument()
    Set docMessage = vwEntry.Document
    Dim strData As String
    strData = docMessage.GetItemValue("Subject")
    MsgBox strData
---------------------------------------------------------------------------------

Keep in mind this works for setting up emails properly. So it isn't an issue of not pointing to the right server or user id, etc...  

The difference is I've added the statements from GetView to the end.
But my vwInbox still equals NOTHING.
Which of course means my vwNav, vwEntry, docMessage will all equal nothing as well.



Thanks for your help!
0
Comment
Question by:BroGreg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
32 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9696658
as long as i see you didn't open the db yet.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9696686
Optionally, you could try with this:
http://www.angelfire.com/realm/vb-shared/notesendmail.htm
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9696727
see this:

Set vwInbox = db.GetView("($Inbox)")
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9696768


Option Explicit

Public doc As Object, rtobject As Object, oB As Object
Public session As Domino.NotesSession

Public db As NotesDatabase
Public dbNotes As Object
Public rtitem As Object
Public wkWKDay As Date
Public wkDayTime As Date
Public blnSentM, blnSentE As Boolean
Public blnSetM, blnSetE As Boolean
Public blnClear As Boolean

Public intRandom As Integer

Public fs As Object

Public user As String, server As String, mailfile As String

Public blnSwitch As Boolean

Public vwInbox As Object
Public vwEntry As Object 'NotesViewEntry
Public vwNav As Object 'NotesViewNavigator

Public docMessage As NotesDocument

'--------------------------------------------------------------------
'Setup Code --------------------------------------------------------------------
'--------------------------------------------------------------------
Sub test()
    Set session = New Domino.NotesSession
    'user = session.UserName
    session.Initialize InputBox$("Please enter Database password.", "Enter Password")
    server = session.GetEnvironmentString("MailServer", True)
    mailfile = session.GetEnvironmentString("MailFile", True)
    Set db = session.GetDatabase(server, mailfile, False) 'InputBox$("Please enter Domino server name here.", "Server name", "FRE-AR-BA-H01"),
                                    'InputBox$("Please enter Domino database name here.", "Enter database name", "\mail\7\ARBA0137.nsf"), _
                                    'False)
With db
    If Not .IsOpen Then
        MsgBox "Unable to open Notes session.", vbCritical, "Init Error"
        Set db = Nothing
        Set session = Nothing
        Exit Sub
    End If
End With
   
       
   ' Set db = session.GetDatabase(server, mailfile)
    'db.Open
    Set vwInbox = db.GetView("($Inbox)")          '  db.GetView("$Inbox")
    Set vwNav = vwInbox.CreateViewNav
    Set vwEntry = vwNav.GetFirstDocument()
    Set docMessage = vwEntry.Document
    Dim strData As String
    strData = docMessage.GetItemValue("Subject")(0)
    MsgBox strData

End Sub
0
 

Author Comment

by:BroGreg
ID: 9701616
VB 6
Lotus 5.0.1
Win XP

I'm getting an error during the  
- session.Initialize InputBox$("Please enter Database password.", "Enter Password")

Could not open the ID file.

Again keep in mind my application for SENDING emails work just fine.
I'm just trying to READ my inbox.  This is why I was trying to reuse my code and just add the necessary code to read my inbox.

My notes ID file is under my profile, so should I move this to a Lotus subdirectory?
Even if it is just for testing purposes?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9701687
Then follow previous comment.
I tested my last and it works with Lotus 5.011 in W2K
Repost:

Set vwInbox = db.GetView("($Inbox)")

0
 

Author Comment

by:BroGreg
ID: 9702886
I've tried the various GetView's  
- db.GetView("Inbox")
- db.GetView("$Inbox")
- db.GetView("(Inbox)")
- db.GetView("($Inbox)")  << This yields and error

Still
wvInbox = nothing.

So you are saying you are able to get this to work without using the session.initialize on a W2K system using 5.011 by just adding the db.getview?

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9702933
Please, do this and try:
Create a new empty exe project, add a reference to Domino libraries (not Lotus OLE automation)

Paste the code from comment at 11/06/2003 12:51PM PST
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9702940
of course, you need to change server name and mail db ;)
0
 

Author Comment

by:BroGreg
ID: 9703445
I did that already.   This is when I get the session.initialization error after putting in my password.

Run-time error '-2147217504 (80040fa0)'

Notes error: Could not open the ID file



Once I solve this error everything else will probably fall into place.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9703874
Please, download example file at:
http://www.angelfire.com/realm/vb-shared/brogreg.xls
0
 

Author Comment

by:BroGreg
ID: 9740431
I tried the download and I'm still getting the same error as I commented above once I put in the password at the stage of session.initilization.

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9740702
Please, could you trace the code (F8) and see what happens with variables values and objects?
0
 

Author Comment

by:BroGreg
ID: 9740747
Maybe this will help...

Multiple Profiles?
Do I need to set a path or something?
The program I wrote that sends email I don't login because I wasn't concerned about that part.    I ran it while already logged on.

I tried the code given to me by this board with Lotus not started AND with Lotus logged on with My Mail open.    So I'm trying different things with the suggestions, but the     session.initialization    is where I keep getting the error.

So I'm wondering do I need to have a statement in there that states a path because my computer does use user profiles though my system is not shared by other users.

It is your typical. Admin, Guest(limited access), and My profile.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9740839
Well, i know nothing about Profiles but could you try to avoid session part and try with the rest of the code. I cannot test it by myself since i don't use Profiles.
0
 

Author Comment

by:BroGreg
ID: 9747829
Avoid the session part?

Isn't this code based off of the session?

Without the session part I will/am getting object errors.

I really think this has to do with setting some type of path or something for this to work.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9748211
"...setting some type of path ..."
What are you thinking?
0
 

Author Comment

by:BroGreg
ID: 9748610
Just an idea I read somewhere.
I wish I had bookmarked this article, but I read somewhere where someone had to change something either in the registry or notes.ini file.

Reading the error "Could not open the ID file"  makes me think it cannot open the file because it cannot find it, there is an access issue, etc....
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9748672
Then, where is located id file?
some paths should be wrote as:
"mail\0\arba0000.id"
and others
"mail/0/arba0000.id"
i don't know why but that's it.

0
 

Author Comment

by:BroGreg
ID: 9749801
In my notes.ini i says:
mail\arba0000.id

The file itself is in:
 program files\lotus\notes
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9750048
"The file itself is in:
 program files\lotus\notes
"

should it be at:
 program files\lotus\notes\arba0000.id
?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9750053
By the way, if i use your code as was first posted, i get all kinds of Automation errors, could you believe it?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9750166
0
 

Author Comment

by:BroGreg
ID: 9750407
You mean the code that I use to send email?
Keep in mind when I use that code... I'm already logged on to Lotus with my email open.
Otherwise errors will definitely pop up.

I'll take a look at the link you provided and see if anything catch my eye.
Thanks for hanging in there with me.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9750594
reading that i saw some words regarding where server is located, so some methods could be used if client/server are in the same machine and will fail if both are in diferent PC and viceversa.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9798323
i got this with success:

Sub test()
Dim o As Object, db As Object
Set o = GetObject(vbNullString, "notes.Notessession")
Set db = o.CurrentDatabase
Set vwInbox = db.GetView("($Inbox)")        
Set vwDoc = vwInbox.GetFirstDocument()
Dim strData As String
strData = vwDoc.GetItemValue("Subject")(0)
MsgBox strData

End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9824343
Well, some feedback would be nice.
in the meantime, could try this?


'your code
...
...
...
...
Set session = CreateObject("notes.notessession")
    user = session.UserName
    server = session.GetEnvironmentString("MailServer", True)
    mailfile = session.GetEnvironmentString("MailFile", True)
       
    Set db = session.GetDatabase(server, mailfile)

    '*************
    'inserted code by RS
    dim v as variant, idx as integer
    v = db.views
    for idx=0 to ubound(v)
          set vwInbox = v(idx)
          if instr(1,vwInbox.name,"inbox",vbtextcompare) then exit for
    next idx
    'end inserted code
    '*************

    Set vwNav = vwInbox.CreateViewNav
    Set vwEntry = vwNav.GetFirstDocument()
    Set docMessage = vwEntry.Document
    Dim strData As String
    strData = docMessage.GetItemValue("Subject")
    MsgBox strData
0
 

Expert Comment

by:alvin082700
ID: 9828909
Listening. This is what works for me on my development environment. This code is in VBA btw. When I migrate it to my client's environment I do get errors right on session.initialize. It returns the error that it cannot find the ID file. I believe it has to do with the way Lotus Notes is set up in their environment. I'd like to find a solution to this.

Function receiveLotusMail()
    Dim session As Object
    Dim domDoc As Object
    'Dim domDocColl As Object
    Dim i As Integer
    Dim db As Object
    Dim objNotesField As Object
    Dim notesObj As Object
    Dim author As Variant
    Dim rt As Object
    Dim dotPos As Integer
    Dim fileStr As String
    Dim xlApp As Object
    Dim wBook As Object
    Dim wSheet As Object
    Dim reportID As Long
    Dim xlRange As Object
    Dim fso As New FileSystemObject
    Dim rs As New ADODB.Recordset
    Dim rsgen As New rsGenerator
    Dim reportRs As New ADODB.Recordset
    Dim vwInbox As Object
   
    On Error GoTo recvLotusMail_ErrorHandler
   
    receiveLotusMail = 0
    Set session = CreateObject("lotus.Notessession")
    'Set domDoc = CreateObject("Notes.NotesDocument")
    'Set domDocColl = CreateObject("Notes.NotesDocumentCollection")
    'Set Db = CreateObject("Notes.NotesDatabase")
    'Set notesObj = CreateObject("Notes.NotesEmbeddedObject")
    'Set rt = CreateObject("Notes.NotesRichTextItem")
    'Set vwInbox = CreateObject("Notes.NotesView")
   
    Call session.Initialize("")

    Set rs = rsgen.rsGenerate("up_QueryMailSettings", , , , True) 'Calls stored procedure to get the mail server file
    Set db = session.GetDatabase(rs("MailServer"), rs("SMTIn"))

    If Not db.IsOpen Then
         MsgBox "The mail database is not open!", vbCritical
         GoTo recvLotusMail_Exit
    Else
        'Process only documents in the Inbox
        Set vwInbox = db.GetView("$inbox")
       
        With vwInbox
            Set domDoc = .GetLastDocument
            Do
                If domDoc Is Nothing Then
                    Exit Do
                End If
                   
                If domDoc.HasEmbedded Then
                Set rt = domDoc.GetFirstItem("body")
                Dim o As Variant
                For Each o In rt.EmbeddedObjects
                    'CODE SNIPPED
                Next
                Set domDoc = .GetPrevDocument(domDoc)
            End If
            Loop Until domDoc Is Nothing
        End With
        Set rt = Nothing
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 10486620
There are, at least, four code options to try the problem here.
0
 

Accepted Solution

by:
amp072397 earned 0 total points
ID: 10528535
PAQed - no points refunded (of 500)

amp
Community Support Moderator amp~at~experts-exchange.com
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

724 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