Ask the Expert

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 =
 "<20030702151524.57275282A
@mailhost11.lists.techtarget.com>"
  
  Set db = s.GetDatabase("server", 
"mailfilename")
  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)
  Wend
  
singleExit:
  
End Sub

This was first published in September 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: