<br>{*******************************************************}<br>{ }<br>{ Borland Delphi Runtime Library }<br>{ Simple MAPI Interface Unit }<br>{ }<br>{ Copyright (C) 1996,99 Inprise Corporation }<br>{ }<br>{*******************************************************}<br><br>unit Mapi;<br><br>{NOTE: Do not place the $NOPACKAGEUNIT directive in this file}<br><br>interface<br><br>uses Windows;<br><br>{<br> Messaging Applications Programming Interface.<br><br> Purpose:<br><br> This file defines the structures and constants used by that<br> subset of the Messaging Applications Programming Interface<br> which is supported under Windows by Microsoft Mail for PC<br> Networks version 3.x.<br>}<br><br>(*$HPPEMIT '#include <mapi.h>'*)<br><br>type<br> {$EXTERNALSYM FLAGS}<br> FLAGS = Cardinal;<br> {$EXTERNALSYM LHANDLE}<br> LHANDLE = Cardinal;<br> PLHANDLE = ^Cardinal;<br><br>const<br> {$EXTERNALSYM lhSessionNull}<br> lhSessionNull = (0);<br><br>type<br> PMapiFileDesc = ^TMapiFileDesc;<br> {$EXTERNALSYM MapiFileDesc}<br> MapiFileDesc = packed record<br> ulReserved: Cardinal; { Reserved for future use (must be 0) }<br> flFlags: Cardinal; { Flags }<br> nPosition: Cardinal; { character in text to be replaced by attachment }<br> lpszPathName: LPSTR; { Full path name of attachment file }<br> lpszFileName: LPSTR; { Original file name (optional) }<br> lpFileType: Pointer; { Attachment file type (can be lpMapiFileTagExt) }<br> end;<br> TMapiFileDesc = MapiFileDesc;<br><br>const<br> {$EXTERNALSYM MAPI_OLE}<br> MAPI_OLE = $00000001;<br> {$EXTERNALSYM MAPI_OLE_STATIC}<br> MAPI_OLE_STATIC = $00000002;<br><br><br>type<br> PMapiFileTagExt = ^TMapiFileTagExt;<br> {$EXTERNALSYM MapiFileTagExt}<br> MapiFileTagExt = packed record<br> ulReserved: Cardinal; { Reserved, must be zero. }<br> cbTag: Cardinal; { Size (in bytes) of }<br> lpTag: PByte; { X.400 OID for this attachment type }<br> cbEncoding: Cardinal; { Size (in bytes) of }<br> lpEncoding: PByte; { X.400 OID for this attachment's encoding }<br> end;<br> TMapiFileTagExt = MapiFileTagExt;<br><br><br> PMapiRecipDesc = ^TMapiRecipDesc;<br> {$EXTERNALSYM MapiRecipDesc}<br> MapiRecipDesc = packed record<br> ulReserved: Cardinal; { Reserved for future use }<br> ulRecipClass: Cardinal; { Recipient class }<br> { MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG }<br> lpszName: LPSTR; { Recipient name }<br> lpszAddress: LPSTR; { Recipient address (optional) }<br> ulEIDSize: Cardinal; { Count in bytes of size of pEntryID }<br> lpEntryID: Pointer; { System-specific recipient reference }<br> end;<br> TMapiRecipDesc = MapiRecipDesc;<br><br>const<br> {$EXTERNALSYM MAPI_ORIG}<br> MAPI_ORIG = 0; { Recipient is message originator }<br> {$EXTERNALSYM MAPI_TO}<br> MAPI_TO = 1; { Recipient is a primary recipient }<br> {$EXTERNALSYM MAPI_CC}<br> MAPI_CC = 2; { Recipient is a copy recipient }<br> {$EXTERNALSYM MAPI_BCC}<br> MAPI_BCC = 3; { Recipient is blind copy recipient }<br><br>type<br> PMapiMessage = ^TMapiMessage;<br> {$EXTERNALSYM MapiMessage}<br> MapiMessage = packed record<br> ulReserved: Cardinal; { Reserved for future use (M.B. 0) }<br> lpszSubject: LPSTR; { Message Subject }<br> lpszNoteText: LPSTR; { Message Text }<br> lpszMessageType: LPSTR; { Message Class }<br> lpszDateReceived: LPSTR; { in YYYY/MM/DD HH:MM format }<br> lpszConversationID: LPSTR; { conversation thread ID }<br> flFlags: FLAGS; { unread,return receipt }<br> lpOriginator: PMapiRecipDesc; { Originator descriptor }<br> nRecipCount: Cardinal; { Number of recipients }<br> lpRecips: PMapiRecipDesc; { Recipient descriptors }<br> nFileCount: Cardinal; { # of file attachments }<br> lpFiles: PMapiFileDesc; { Attachment descriptors }<br> end;<br> TMapiMessage = MapiMessage;<br><br>const<br> {$EXTERNALSYM MAPI_UNREAD}<br> MAPI_UNREAD = $00000001;<br> {$EXTERNALSYM MAPI_RECEIPT_REQUESTED}<br> MAPI_RECEIPT_REQUESTED = $00000002;<br> {$EXTERNALSYM MAPI_SENT}<br> MAPI_SENT = $00000004;<br><br><br>{ Entry points. }<br><br>{ flFlags values for Simple MAPI entry points. All documented flags are<br> shown for each call. Duplicates are commented out but remain present<br> for every call. }<br><br>{ MAPILogon() flags. }<br><br> {$EXTERNALSYM MAPI_LOGON_UI}<br> MAPI_LOGON_UI = $00000001; { Display logon UI }<br> {$EXTERNALSYM MAPI_PASSWORD_UI}<br> MAPI_PASSWORD_UI = $00020000; { prompt for password only }<br> {$EXTERNALSYM MAPI_NEW_SESSION}<br> MAPI_NEW_SESSION = $00000002; { Don't use shared session }<br> {$EXTERNALSYM MAPI_FORCE_DOWNLOAD}<br> MAPI_FORCE_DOWNLOAD = $00001000; { Get new mail before return }<br> {$EXTERNALSYM MAPI_ALLOW_OTHERS}<br> MAPI_ALLOW_OTHERS = $00000008; { Make this a shared session (removed from 4.0 SDK) }<br> {$EXTERNALSYM MAPI_EXPLICIT_PROFILE}<br> MAPI_EXPLICIT_PROFILE = $00000010; { Don't use default profile (removed from 4.0 SDK) }<br> {$EXTERNALSYM MAPI_EXTENDED}<br> MAPI_EXTENDED = $00000020; { Extended MAPI Logon }<br> {$EXTERNALSYM MAPI_USE_DEFAULT}<br> MAPI_USE_DEFAULT = $00000040; { Use default profile in logon (removed from 4.0 SDK) }<br><br> {$EXTERNALSYM MAPI_SIMPLE_DEFAULT}<br> MAPI_SIMPLE_DEFAULT = MAPI_LOGON_UI or MAPI_FORCE_DOWNLOAD or MAPI_ALLOW_OTHERS; { removed from 4.0 SDK }<br> {$EXTERNALSYM MAPI_SIMPLE_EXPLICIT}<br> MAPI_SIMPLE_EXPLICIT = MAPI_NEW_SESSION or MAPI_FORCE_DOWNLOAD or MAPI_EXPLICIT_PROFILE; { removed from 4.0 SDK }<br><br>{ MAPILogoff() flags. }<br><br> {$EXTERNALSYM MAPI_LOGOFF_SHARED}<br> MAPI_LOGOFF_SHARED = $00000001; { Close all shared sessions (removed from 4.0 SDK) }<br> {$EXTERNALSYM MAPI_LOGOFF_UI}<br> MAPI_LOGOFF_UI = $00000002; { It's OK to present UI (removed from 4.0 SDK) }<br><br>{ MAPISendMail() flags. }<br><br>{ #define MAPI_LOGON_UI 0x00000001 Display logon UI }<br>{ #define MAPI_NEW_SESSION 0x00000002 Don't use shared session }<br> {$EXTERNALSYM MAPI_DIALOG}<br> MAPI_DIALOG = $00000008; { Display a send note UI }<br>{ # define MAPI_USE_DEFAULT 0x00000040 Use default profile in logon }<br><br>{ MAPIFindNext() flags. }<br><br> {$EXTERNALSYM MAPI_UNREAD_ONLY}<br> MAPI_UNREAD_ONLY = $00000020; { Only unread messages }<br> {$EXTERNALSYM MAPI_GUARANTEE_FIFO}<br> MAPI_GUARANTEE_FIFO = $00000100; { use date order }<br> {$EXTERNALSYM MAPI_LONG_MSGID}<br> MAPI_LONG_MSGID = $00004000; { allow 512 char returned ID }<br><br>{ MAPIReadMail() flags. }<br><br> {$EXTERNALSYM MAPI_PEEK}<br> MAPI_PEEK = $00000080; { Do not mark as read. }<br> {$EXTERNALSYM MAPI_SUPPRESS_ATTACH}<br> MAPI_SUPPRESS_ATTACH = $00000800; { header + body, no files }<br> {$EXTERNALSYM MAPI_ENVELOPE_ONLY}<br> MAPI_ENVELOPE_ONLY = $00000040; { Only header information }<br> {$EXTERNALSYM MAPI_BODY_AS_FILE}<br> MAPI_BODY_AS_FILE = $00000200;<br><br>{ MAPISaveMail() flags. }<br><br>{ #define MAPI_LOGON_UI 0x00000001 Display logon UI }<br>{ #define MAPI_NEW_SESSION 0x00000002 Don't use shared session }<br>{ #define MAPI_LONG_MSGID 0x00004000 /* allow 512 char returned ID }<br><br>{ MAPIAddress() flags. }<br><br>{ #define MAPI_LOGON_UI 0x00000001 Display logon UI }<br>{ #define MAPI_NEW_SESSION 0x00000002 Don't use shared session }<br><br>{ MAPIDetails() flags. }<br><br>{ #define MAPI_LOGON_UI 0x00000001 Display logon UI }<br>{ #define MAPI_NEW_SESSION 0x00000002 Don't use shared session }<br> {$EXTERNALSYM MAPI_AB_NOMODIFY}<br> MAPI_AB_NOMODIFY = $00000400; { Don't allow mods of AB entries }<br><br>{ MAPIResolveName() flags. }<br><br>{ #define MAPI_LOGON_UI 0x00000001 Display logon UI }<br>{ #define MAPI_NEW_SESSION 0x00000002 Don't use shared session }<br>{ #define MAPI_DIALOG 0x00000008 Prompt for choices if ambiguous }<br>{ #define MAPI_AB_NOMODIFY 0x00000400 Don't allow mods of AB entries }<br><br>type<br> PFNMapiLogon = ^TFNMapiLogOn;<br> TFNMapiLogOn = function(ulUIParam: Cardinal; lpszProfileName: LPSTR;<br> lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> lplhSession: PLHANDLE): Cardinal stdcall;<br><br> PFNMapiLogOff = ^TFNMapiLogOff;<br> TFNMapiLogOff = function(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal stdcall;<br><br> PFNMapiSendMail = ^TFNMapiSendMail;<br> TFNMapiSendMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpMessage: TMapiMessage; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal stdcall;<br><br> PFNMapiSendDocuments = ^TFNMapiSendDocuments;<br> TFNMapiSendDocuments = function(ulUIParam: Cardinal; lpszDelimChar: LPSTR;<br> lpszFilePaths: LPSTR; lpszFileNames: LPSTR;<br> ulReserved: Cardinal): Cardinal stdcall;<br><br> PFNMapiFindNext = ^TFNMapiFindNext;<br> TFNMapiFindNext = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;<br> ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal stdcall;<br><br> PFNMapiReadMail = ^TFNMapiReadMail;<br> TFNMapiReadMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> var lppMessage: PMapiMessage): Cardinal stdcall;<br><br> PFNMapiSaveMail = ^TFNMapiSaveMail;<br> TFNMapiSaveMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;<br> lpszMessageID: LPSTR): Cardinal stdcall;<br><br> PFNMapiDeleteMail = ^TFNMapiDeleteMail;<br> TFNMapiDeleteMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageID: LPSTR; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal stdcall;<br><br> PFNMapiFreeBuffer = ^TFNMapiFreeBuffer;<br> TFNMapiFreeBuffer = function(pv: Pointer): Cardinal stdcall;<br><br> PFNMapiAddress = ^TFNMapiAddress;<br> TFNMapiAddress = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;<br> nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;<br> ulReserved: Cardinal; lpnNewRecips: PULONG;<br> var lppNewRecips: PMapiRecipDesc): Cardinal stdcall;<br><br> PFNMapiDetails = ^TFNMapiDetails;<br> TFNMapiDetails = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpRecip: TMapiRecipDesc; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal stdcall;<br><br> PFNMapiResolveName = ^TFNMapiResolveName;<br> TFNMapiResolveName = function(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> var lppRecip: PMapiRecipDesc): Cardinal stdcall;<br><br>const<br> {$EXTERNALSYM SUCCESS_SUCCESS}<br> SUCCESS_SUCCESS = 0;<br> {$EXTERNALSYM MAPI_USER_ABORT}<br> MAPI_USER_ABORT = 1;<br> {$EXTERNALSYM MAPI_E_USER_ABORT}<br> MAPI_E_USER_ABORT = MAPI_USER_ABORT;<br> {$EXTERNALSYM MAPI_E_FAILURE}<br> MAPI_E_FAILURE = 2;<br> {$EXTERNALSYM MAPI_E_LOGON_FAILURE}<br> MAPI_E_LOGON_FAILURE = 3;<br> {$EXTERNALSYM MAPI_E_LOGIN_FAILURE}<br> MAPI_E_LOGIN_FAILURE = MAPI_E_LOGON_FAILURE;<br> {$EXTERNALSYM MAPI_E_DISK_FULL}<br> MAPI_E_DISK_FULL = 4;<br> {$EXTERNALSYM MAPI_E_INSUFFICIENT_MEMORY}<br> MAPI_E_INSUFFICIENT_MEMORY = 5;<br> {$EXTERNALSYM MAPI_E_ACCESS_DENIED}<br> MAPI_E_ACCESS_DENIED = 6;<br> {$EXTERNALSYM MAPI_E_TOO_MANY_SESSIONS}<br> MAPI_E_TOO_MANY_SESSIONS = 8;<br> {$EXTERNALSYM MAPI_E_TOO_MANY_FILES}<br> MAPI_E_TOO_MANY_FILES = 9;<br> {$EXTERNALSYM MAPI_E_TOO_MANY_RECIPIENTS}<br> MAPI_E_TOO_MANY_RECIPIENTS = 10;<br> {$EXTERNALSYM MAPI_E_ATTACHMENT_NOT_FOUND}<br> MAPI_E_ATTACHMENT_NOT_FOUND = 11;<br> {$EXTERNALSYM MAPI_E_ATTACHMENT_OPEN_FAILURE}<br> MAPI_E_ATTACHMENT_OPEN_FAILURE = 12;<br> {$EXTERNALSYM MAPI_E_ATTACHMENT_WRITE_FAILURE}<br> MAPI_E_ATTACHMENT_WRITE_FAILURE = 13;<br> {$EXTERNALSYM MAPI_E_UNKNOWN_RECIPIENT}<br> MAPI_E_UNKNOWN_RECIPIENT = 14;<br> {$EXTERNALSYM MAPI_E_BAD_RECIPTYPE}<br> MAPI_E_BAD_RECIPTYPE = 15;<br> {$EXTERNALSYM MAPI_E_NO_MESSAGES}<br> MAPI_E_NO_MESSAGES = 16;<br> {$EXTERNALSYM MAPI_E_INVALID_MESSAGE}<br> MAPI_E_INVALID_MESSAGE = 17;<br> {$EXTERNALSYM MAPI_E_TEXT_TOO_LARGE}<br> MAPI_E_TEXT_TOO_LARGE = 18;<br> {$EXTERNALSYM MAPI_E_INVALID_SESSION}<br> MAPI_E_INVALID_SESSION = 19;<br> {$EXTERNALSYM MAPI_E_TYPE_NOT_SUPPORTED}<br> MAPI_E_TYPE_NOT_SUPPORTED = 20;<br> {$EXTERNALSYM MAPI_E_AMBIGUOUS_RECIPIENT}<br> MAPI_E_AMBIGUOUS_RECIPIENT = 21;<br> {$EXTERNALSYM MAPI_E_AMBIG_RECIP}<br> MAPI_E_AMBIG_RECIP = MAPI_E_AMBIGUOUS_RECIPIENT;<br> {$EXTERNALSYM MAPI_E_MESSAGE_IN_USE}<br> MAPI_E_MESSAGE_IN_USE = 22;<br> {$EXTERNALSYM MAPI_E_NETWORK_FAILURE}<br> MAPI_E_NETWORK_FAILURE = 23;<br> {$EXTERNALSYM MAPI_E_INVALID_EDITFIELDS}<br> MAPI_E_INVALID_EDITFIELDS = 24;<br> {$EXTERNALSYM MAPI_E_INVALID_RECIPS}<br> MAPI_E_INVALID_RECIPS = 25;<br> {$EXTERNALSYM MAPI_E_NOT_SUPPORTED}<br> MAPI_E_NOT_SUPPORTED = 26;<br><br><br>{ Delphi wrapper calls around Simple MAPI }<br><br>function MapiLogOn(ulUIParam: Cardinal; lpszProfileName: LPSTR;<br> lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> lplhSession: PLHANDLE): Cardinal;<br><br>function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal;<br><br>function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;<br><br>function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR;<br> lpszFilePaths: LPSTR; lpszFileNames: LPSTR; ulReserved: Cardinal): Cardinal;<br><br>function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;<br> ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;<br><br>function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> var lppMessage: PMapiMessage): Cardinal;<br><br>function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;<br> lpszMessageID: LPSTR): Cardinal;<br><br>function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageID: LPSTR; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal;<br><br>function MapiFreeBuffer(pv: Pointer): Cardinal;<br><br>function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;<br> nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;<br> ulReserved: Cardinal; lpnNewRecips: PULONG;<br> var lppNewRecips: PMapiRecipDesc): Cardinal;<br><br>function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpRecip: TMapiRecipDesc; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal;<br><br>function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> var lppRecip: PMapiRecipDesc): Cardinal;<br><br>var<br> MAPIDLL: string = 'MAPI32.DLL';<br><br>implementation<br><br>var<br> MAPIModule: HModule = 0;<br> LogOn: TFNMapiLogOn = nil;<br> LogOff: TFNMapiLogOff = nil;<br> SendMail: TFNMapiSendMail = nil;<br> SendDocuments: TFNMapiSendDocuments = nil;<br> FindNext: TFNMapiFindNext = nil;<br> ReadMail: TFNMapiReadMail = nil;<br> SaveMail: TFNMapiSaveMail = nil;<br> DeleteMail: TFNMapiDeleteMail = nil;<br> FreeBuffer: TFNMapiFreeBuffer = nil;<br> Address: TFNMapiAddress = nil;<br> Details: TFNMapiDetails = nil;<br> ResolveName: TFNMapiResolveName = nil;<br><br>var<br> MAPIChecked: Boolean = False;<br><br>procedure InitMapi;<br>var<br> OSVersionInfo: TOSVersionInfo;<br> hkWMS: HKEY;<br> MAPIValueSize: Longint;<br> MAPIValueBuf: array[0..8] of char;<br> rType: Longint;<br>begin<br> if not MAPIChecked then<br> begin<br> MAPIChecked := True;<br> MAPIModule := 0;<br><br> OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo);<br> GetVersionEx(OSVersionInfo);<br> if (OSVersionInfo.dwMajorVersion > 3) or<br> ((OSVersionInfo.dwMajorVersion = 3) and<br> (OSVersionInfo.dwMinorVersion > 51)) then<br> begin<br> MAPIValueSize := sizeof(MAPIValueBuf);<br> if RegOpenKeyEx(HKEY_LOCAL_MACHINE, 'SOFTWARE/Microsoft/Windows Messaging Subsystem',<br> 0, KEY_READ, hkWMS) <> ERROR_SUCCESS then Exit;<br> if RegQueryValueEx(hkWMS, 'MAPI', nil, @rType, @MAPIValueBuf,<br> @MAPIValueSize) <> ERROR_SUCCESS then Exit;<br> RegCloseKey(hkWMS);<br> if not ((MAPIValueBuf[0] = '1') and (MAPIValueBuf[1] = #0)) then Exit;<br> end<br> else if GetProfileInt('Mail', 'MAPI', 0) = 0 then Exit;<br><br> MAPIModule := LoadLibrary(PChar(MAPIDLL));<br> end;<br>end;<br><br>function MapiLogOn(ulUIParam: Cardinal; lpszProfileName: LPSTR;<br> lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> lplhSession: PLHANDLE): Cardinal;<br>begin<br> InitMapi;<br> if @LogOn = nil then<br> @LogOn := GetProcAddress(MAPIModule, 'MAPILogon');<br> if @LogOn <> nil then<br> Result := LogOn(ulUIParam, lpszProfileName, lpszPassword, flFlags,<br> ulReserved, lplhSession)<br> else Result := 1;<br>end;<br><br>function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal;<br>begin<br> InitMapi;<br> if @LogOff = nil then<br> @LogOff := GetProcAddress(MAPIModule, 'MAPILogoff');<br> if @LogOff <> nil then<br> Result := LogOff(lhSession, ulUIParam, flFlags, ulReserved)<br> else Result := 1;<br>end;<br><br>function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;<br>begin<br> InitMapi;<br> if @SendMail = nil then<br> @SendMail := GetProcAddress(MAPIModule, 'MAPISendMail');<br> if @SendMail <> nil then<br> Result := SendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved)<br> else Result := 1;<br>end;<br><br>function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR;<br> lpszFilePaths: LPSTR; lpszFileNames: LPSTR;<br> ulReserved: Cardinal): Cardinal;<br>begin<br> InitMapi;<br> if @SendDocuments = nil then<br> @SendDocuments := GetProcAddress(MAPIModule, 'MAPISendDocuments');<br> if @SendDocuments <> nil then<br> Result := SendDocuments(ulUIParam, lpszDelimChar, lpszFilePaths,<br> lpszFileNames, ulReserved)<br> else Result := 1;<br>end;<br><br>function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;<br> ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;<br>begin<br> InitMapi;<br> if @FindNext = nil then<br> @FindNext := GetProcAddress(MAPIModule, 'MAPIFindNext');<br> if @FindNext <> nil then<br> Result := FindNext(lhSession, ulUIParam, lpszMessageType,<br> lpszSeedMessageID, flFlags, ulReserved, lpszMessageID)<br> else Result := 1;<br>end;<br><br>function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> var lppMessage: PMapiMessage): Cardinal;<br>begin<br> InitMapi;<br> if @ReadMail = nil then<br> @ReadMail := GetProcAddress(MAPIModule, 'MAPIReadMail');<br> if @ReadMail <> nil then<br> Result := ReadMail(lhSession, ulUIParam, lpszMessageID, flFlags,<br> ulReserved, lppMessage)<br> else Result := 1;<br>end;<br><br>function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;<br> lpszMessageID: LPSTR): Cardinal;<br>begin<br> InitMapi;<br> if @SaveMail = nil then<br> @SaveMail := GetProcAddress(MAPIModule, 'MAPISaveMail');<br> if @SaveMail <> nil then<br> Result := SaveMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved,<br> lpszMessageID)<br> else Result := 1;<br>end;<br><br>function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszMessageID: LPSTR; flFlags: FLAGS;<br> ulReserved: Cardinal): Cardinal;<br>begin<br> InitMapi;<br> if @DeleteMail = nil then<br> @DeleteMail := GetProcAddress(MAPIModule, 'MAPIDeleteMail');<br> if @DeleteMail <> nil then<br> Result := DeleteMail(lhSession, ulUIParam, lpszMessageID, flFlags,<br> ulReserved)<br> else Result := 1;<br>end;<br><br>function MapiFreeBuffer(pv: Pointer): Cardinal;<br>begin<br> InitMapi;<br> if @FreeBuffer = nil then<br> @FreeBuffer := GetProcAddress(MAPIModule, 'MAPIFreeBuffer');<br> if @FreeBuffer <> nil then<br> Result := FreeBuffer(pv)<br> else Result := 1;<br>end;<br><br>function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;<br> nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;<br> ulReserved: Cardinal; lpnNewRecips: PULONG;<br> var lppNewRecips: PMapiRecipDesc): Cardinal;<br>begin<br> InitMapi;<br> if @Address = nil then<br> @Address := GetProcAddress(MAPIModule, 'MAPIAddress');<br> if @Address <> nil then<br> Result := Address(lhSession, ulUIParam, lpszCaption, nEditFields,<br> lpszLabels, nRecips, lpRecips, flFlags, ulReserved, lpnNewRecips,<br> lppNewRecips)<br> else Result := 1;<br>end;<br><br>function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;<br> var lpRecip: TMapiRecipDesc; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;<br>begin<br> InitMapi;<br> if @Details = nil then<br> @Details := GetProcAddress(MAPIModule, 'MAPIDetails');<br> if @Details <> nil then<br> Result := Details(lhSession, ulUIParam, lpRecip, flFlags, ulReserved)<br> else Result := 1;<br>end;<br><br>function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;<br> lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;<br> var lppRecip: PMapiRecipDesc): Cardinal;<br>begin<br> InitMapi;<br> if @ResolveName = nil then<br> @ResolveName := GetProcAddress(MAPIModule, 'MAPIResolveName');<br> if @ResolveName <> nil then<br> Result := ResolveName(lhSession, ulUIParam, lpszName, flFlags,<br> ulReserved, lppRecip)<br> else Result := 1;<br>end;<br><br>initialization<br>finalization<br> if MAPIModule <> 0 then FreeLibrary(MAPIModule);<br>end.<br>