Sending email via Lotus Notes or cc:Mail

This document illustrates how to send email from the 24x7 Scheduler using DDE to Lotus Notes or cc:Mail.

The following code uses DDE with Lotus Notes to show how to Lotus mail-enable 24x7 Scheduler.  Lotus cc:Mail recognizes the same DDE commands.

First, check the LotusMail group in WIN.INI to find which mail program is installed and its execution path. The entry for cc:Mail should look something like this:

[LotusMail]
Application=wmail
Program=c:\ccmail\wmail.exe SendMail


For Notes:

[LotusMail]
Application=Notes
Program=c:\notes\notes.exe

Dim MailProgram, string
Dim Channel, number
Dim MailIsNotRunning, boolean
Dim ProcessHandle, number

IniFileGetKey "win.ini", "LotusMail", "Program", MailProgram
//Try conversing with Notes to see if it is already active...
DDEOpen "Notes", "SendMail", Channel

//If Notes not running, start it
IsLess Channel, 1, MailIsNotRunning
If MailIsNotRunning MAIL_RUNNING
Run MailProgram, "", ProcessHandle
Wait 60
DDEOpen "Notes", "SendMail", Channel

        // check if DDE channel was opened
        IsLess Channel, 1, MailIsNotRunning
        If MailIsNotRunning MAIL_RUNNING
        LogAddMessage "Failed to open channel to Lotus Notes or cc:Mail"
        exit
MAIL_RUNNING

//Here if Notes is active, so start a new message in Notes
DDEExecute Channel, "NewMessage"
DDEExecute Channel, "To username@domain.name"
DDEExecute Channel, "CC cc_username@domain.name"
DDEExecute Channel, "Subject Message from 24x7 Scheduler"
DDEExecute Channel, "Text This is message text"
DDEExecute Channel, "AttachFile c:\temp\test.txt"
DDEExecute Channel, "Send"
// Done, disconnect from Notes.
DDEClose Channel

Notes:
1. See the cc:Mail for Windows User's Guide for DDE info.
2. For Notes DDE specifics and additional syntax, see the Mail DDE document in the Notes Release Notes database.