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

VB 6 / Lotus 5.0.1 / View Inbox:

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
BroGreg
Asked:
BroGreg
1 Solution
 
Richie_SimonettiIT OperationsCommented:
as long as i see you didn't open the db yet.
0
 
Richie_SimonettiIT OperationsCommented:
Optionally, you could try with this:
http://www.angelfire.com/realm/vb-shared/notesendmail.htm
0
 
Richie_SimonettiIT OperationsCommented:
see this:

Set vwInbox = db.GetView("($Inbox)")
0
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.

 
Richie_SimonettiIT OperationsCommented:


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
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
Then follow previous comment.
I tested my last and it works with Lotus 5.011 in W2K
Repost:

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

0
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
of course, you need to change server name and mail db ;)
0
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
Please, download example file at:
http://www.angelfire.com/realm/vb-shared/brogreg.xls
0
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
Please, could you trace the code (F8) and see what happens with variables values and objects?
0
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
"...setting some type of path ..."
What are you thinking?
0
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
BroGregAuthor Commented:
In my notes.ini i says:
mail\arba0000.id

The file itself is in:
 program files\lotus\notes
0
 
Richie_SimonettiIT OperationsCommented:
"The file itself is in:
 program files\lotus\notes
"

should it be at:
 program files\lotus\notes\arba0000.id
?
0
 
Richie_SimonettiIT OperationsCommented:
By the way, if i use your code as was first posted, i get all kinds of Automation errors, could you believe it?
0
 
Richie_SimonettiIT OperationsCommented:
0
 
BroGregAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
alvin082700Commented:
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
 
Richie_SimonettiIT OperationsCommented:
There are, at least, four code options to try the problem here.
0
 
amp072397Commented:
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.

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