MAIN
DEFINE result, id INTEGER
DEFINE str STRING
-- first, we initialize the module
CALL ui.Interface.frontCall("WinMail", "Init", [], [id])
-- Set the body of the mail
CALL ui.interface.frontCall("WinMail", "SetBody",
[id, "This is a text mail using WinMail API - MAPI"], [result])
-- Set the subject of the mail
CALL ui.interface.frontCall("WinMail", "SetSubject",
[id, "test mail - ignore it"], [result])
-- Add an Addressee as "TO"
CALL ui.Interface.frontCall("WinMail", "AddTo",
[id, "myBoss", "boss@mycompany.com"], [result])
-- Add another Addresse as "BCC"
CALL ui.Interface.frontCall("WinMail", "AddBCC",
[id, "my friend", "friend@mycompany.com"], [result])
-- Add Two attachments
CALL ui.Interface.frontCall("WinMail", "AddAttachment",
[id, "c:\\mydocs\report.doc"], [result])
CALL ui.Interface.frontCall("WinMail", "AddAttachment",
[id, "c:\\mydocs\demo.png"], [result])
-- Send the mail via the default mailer
CALL ui.Interface.frontCall("WinMail", "SendMailMAPI", [id], [result])
IF result == TRUE THEN
DISPLAY "Message sent successfully"
ELSE
CALL ui.Interface.frontCall("WinMail", "GetError", [id], [str])
DISPLAY str
END IF
CALL ui.Interface.frontCall("WinMail", "Close", [id], [result])
END MAIN