Fetch e-mails in Domino using Java

I am trying to fetch e-mail messages in Domino using Java (DCO and Lotus Domino packages). I want to fetch messages with a given message ID from the user's inbox folder. How do I do that?
The Message ID is contained in the $MessageID field. For example, a newsletter from SearchDomino.com had the message ID "<20030702151524.57275282A@mailhost11.lists.techtarget.com>". To get a handle on this document in a users inbox, you could use the following code:
Sub Initialize
  Dim s As New NotesSession
  Dim db As NotesDatabase
  Dim view As NotesView
  Dim doc As NotesDocument
  Dim docNext As NotesDocument
  Dim item As NotesItem
  Dim strMessageID As String
  strMessageID =
  Set db = s.GetDatabase("server", 
  Set view = "($InBox)"
  Set doc = view.GetFirstDocument
  While Not(doc Is Nothing)
    Set item = doc.GetFirstItem("$MessasgeID")
    If item.text = MessageID Then
      ' --- add whatever code you need to 
'process the document the way you wish
      ' --- possibly : Call doc.Remove
      Goto singleExit
    End If
    Set doc = dc.GetNextDocument(doc)
End Sub

This was last published in September 2003

Dig Deeper on Domino Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...