Code: Select all
// FiveWin OLE support demo
// Using Microsoft MAPI Control
// By Rochinha - Brazil
#include "FiveWin.ch"
#define SESSION_SIGNON 1
#define MESSAGE_COMPOSE 6
#define ATTACHTYPE_DATA 0
#define RECIPTYPE_TO 1
#define RECIPTYPE_CC 2
#define MESSAGE_RESOLVENAME 13
#define MESSAGE_SEND 3
#define SESSION_SIGNOFF 2
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "FiveWin OLE Support"
MapiSession1 := TOleAuto():New( "MSMAPI.MAPISession.1" )
MapiMessages1 := TOleAuto():New( "MSMAPI.MAPImessages.1" )
//MapiSession1:aboutbox()
//Open up a MAPI session
MapiSession1:Action := SESSION_SIGNON
//Point the MAPI messages control to the open MAPI session:
MapiMessages1:SessionID := 1
MapiMessages1:Action := MESSAGE_COMPOSE //Start a new message
// Set the subject of the message:
MapiMessages1:MsgSubject := "This is the subject."
// Set the message content
MapiMessages1:MsgNoteText:= "This is the mail message."
// The following four lines of code add an attachment to the message,
// and set the character position within the MsgNoteText where the
// attachment icon will appear. A value of 0 means the attachment will
// replace the first character in the MsgNoteText. You must have at
// least one character in the MsgNoteText to be able to attach a file.
MapiMessages1:AttachmentPosition := 0
// Set the type of attachment
MapiMessages1:AttachmentType := ATTACHTYPE_DATA
// Set the icon title of attachment:
MapiMessages1:AttachmentName := "System Configuration File"
// Set the path and file name of the attachment:
MapiMessages1:AttachmentPathName := "C:\CONFIG.SYS"
// Set the recipients
MapiMessages1:RecipIndex := 0 // First recipient
MapiMessages1:RecipType := RECIPTYPE_TO // Recipient in TO line
MapiMessages1:RecipDisplayName := "EddieSpaghetti" // e-mail name
MapiMessages1:RecipIndex := 1 // add a second recipient
MapiMessages1:RecipType := RECIPTYPE_TO // Recipient in TO line
MapiMessages1:RecipDisplayName := "TanyaLasagna" // e-mail name
MapiMessages1:RecipIndex := 2 // Add a third recipient
MapiMessages1:RecipType := RECIPTYPE_CC // Recipient in CC line
MapiMessages1:RecipDisplayName := "BlairAngelHair" // e-mail name
MapiMessages1:RecipIndex := 3 // Add a fourth recipient
MapiMessages1:RecipType := RECIPTYPE_CC // Recipient on CC Line
MapiMessages1:RecipDisplayName := "JoanieCannelloni" // e-mail name"
// MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts
// the recipient address in MapiMessages1:RecipAddress
// If the E-Mail name is not valid, a trappable error will occur.
MapiMessages1:Action := MESSAGE_RESOLVENAME
// Send the message:
MapiMessages1:Action := MESSAGE_SEND
// Close MAPI mail session:
MapiSession1:Action := SESSION_SIGNOFF
ACTIVATE WINDOW oWnd
return nil
http://home.wxs.nl/~hafoh000/MSMAPI32.zip