Reading Lotus Notes Email from Visual Basic


Here's what I have so far:

Private Sub cmdReceive_Click()
    Dim myLotus As Object
    Dim db As Object
    Dim strUserName As String
    Dim strServer As String
    Dim strMailfile As String
    Dim MailItems As Object
    Dim MailItem As Object
    Dim messageCount As Integer
    Dim strAuthor As String
    Dim strBody As String
    Dim x As Integer
    Dim fso As New FileSystemObject
    Const strSavePath As String = "S:\Defence\DMIS\TIR\Admin\Download"
    Set myLotus = CreateObject("notes.notessession")
    strUserName = myLotus.USERNAME
    strServer = myLotus.GETENVIRONMENTSTRING("MailServer", True)
    strMailfile = myLotus.GETENVIRONMENTSTRING("MailFile", True)
    Set db = myLotus.GETDATABASE(strServer, strMailfile)
    If Not db.ISOPEN Then
    End If
    Set MailItems = db.ALLDOCUMENTS
    Set MailItem = MailItems.GETLASTDOCUMENT
    strBody = MailItem.body
    strAuthor = Join(MailItem.AUTHORS)
    messageCount = MailItems.Count
    Debug.Print MailItem.body
   For x = 0 To messageCount - 1
        Set MailItem = MailItems.GETPREVDOCUMENT(MailItem)
        Debug.Print MailItem.body
    Next x
End Sub

This seems to work good enough. What I REALLY need to know is how can I only get emails from a certain folder (Example: Inbox), and how can I only get messages that have been unread?

What this program will eventually do is look through all unread emails, and ones from a certain author will have the body dumped into a text file on a network drive.

Your help is greatly appreciated!!!

Thanks in advance,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hey man i can help you with the inbox folder, but the unread mail is very hard to find some help (i have 4 months, investigating how to program lotus stuff in VB), i have the same problem, by the way is the only thing i need to finish my program interface with lotus, if you find the solution please forward me, ok this is the sample for the inbox view.

    Set NTSVIEW = Maildb.GetView("($Inbox)")
    Set MAILDOC = NTSVIEW.GetFirstDocument
    Do While Not MAILDOC Is Nothing
        Cant = Cant + 1
        Set MAILDOC = NTSVIEW.GetNextDocument(MAILDOC)

This code count the emails in the inbox folder, but i can´t find any property for the unread mail.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.