Reading Lotus Notes Email from Visual Basic

Posted on 2003-02-25
Medium Priority
Last Modified: 2013-11-25

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,

Question by:chadz
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
1 Comment

Accepted Solution

PercyHH earned 320 total points
ID: 8028304
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 pjherrera@alfagrp.com, 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.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

752 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