Calling mail functions from lotus agent

A classic Lotus Notes question!

To call mail functions from a Lotus Agent, you can use the SendMail and GetMail methods provided by the Lotus Notes API. Here's a brief overview of how to use them:

SendMail

The SendMail method allows you to send a new email message from your Lotus Agent. You can specify the recipient, subject, body, and attachments.

Here's an example of how to use SendMail:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim mail As NotesMail

Set db = session.CurrentDatabase
Set doc = db.GetDocumentByID("your_document_id")
Set mail = New NotesMail

mail.To = "[email protected]"
mail.Subject = "Test email from Lotus Agent"
mail.Body = "This is a test email sent from a Lotus Agent."
mail.Send

Set mail = Nothing
Set doc = Nothing
Set db = Nothing
Set session = Nothing

GetMail

The GetMail method allows you to retrieve a specific email message from the mail database. You can use it to retrieve a message by its ID, subject, or sender.

Here's an example of how to use GetMail:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim mail As NotesMail

Set db = session.CurrentDatabase
Set mail = db.GetMail("your_message_id")

If Not mail Is Nothing Then
    Print mail.Subject
    Print mail.Body
End If

Set mail = Nothing
Set db = Nothing
Set session = Nothing

Additional Tips