Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

Reading Lotus Notes Email from Visual Basic

Hello,

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
        db.OPENMAIL
    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,

Chad
0
chadz
Asked:
chadz
1 Solution
 
PercyHHCommented:
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)
    Loop

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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