home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / MAPI.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-08  |  19KB  |  492 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       Simple MAPI Interface Unit                      }
  6. {                                                       }
  7. {       Copyright (c) 1996 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Mapi;
  12.  
  13. interface
  14.  
  15. uses Windows;
  16.  
  17. {
  18.   Messaging Applications Programming Interface.
  19.  
  20.   Purpose:
  21.  
  22.     This file defines the structures and constants used by that
  23.     subset of the Messaging Applications Programming Interface
  24.     which is supported under Windows by Microsoft Mail for PC
  25.     Networks version 3.x.
  26. }
  27.  
  28.  
  29. type
  30.   FLAGS = Cardinal;
  31.   LHANDLE = Cardinal;
  32.   PLHANDLE = ^Cardinal;
  33.  
  34. const
  35.   lhSessionNull = (0);
  36.  
  37. type
  38.   PMapiFileDesc = ^TMapiFileDesc;
  39.   TMapiFileDesc = packed record
  40.     ulReserved: Cardinal;        { Reserved for future use (must be 0)     }
  41.     flFlags: Cardinal;           { Flags                                   }
  42.     nPosition: Cardinal;         { character in text to be replaced by attachment }
  43.     lpszPathName: LPSTR;         { Full path name of attachment file       }
  44.     lpszFileName: LPSTR;         { Original file name (optional)           }
  45.     lpFileType: Pointer;         { Attachment file type (can be lpMapiFileTagExt) }
  46.   end;
  47.  
  48. const
  49.   MAPI_OLE = $00000001; 
  50.   MAPI_OLE_STATIC = $00000002; 
  51.  
  52.  
  53. type
  54.   PMapiFileTagExt = ^TMapiFileTagExt;
  55.   TMapiFileTagExt = packed record 
  56.     ulReserved: Cardinal;       { Reserved, must be zero.                  }
  57.     cbTag: Cardinal;            { Size (in bytes) of                       }
  58.     lpTag: PByte;               { X.400 OID for this attachment type       }
  59.     cbEncoding: Cardinal;       { Size (in bytes) of                       }
  60.     lpEncoding: PByte;          { X.400 OID for this attachment's encoding }
  61.   end;
  62.  
  63.  
  64.   PMapiRecipDesc = ^TMapiRecipDesc;
  65.   TMapiRecipDesc = packed record 
  66.     ulReserved: Cardinal;       { Reserved for future use                  }
  67.     ulRecipClass: Cardinal;     { Recipient class                          }
  68.                                 { MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG    }
  69.     lpszName: LPSTR;            { Recipient name                           }
  70.     lpszAddress: LPSTR;         { Recipient address (optional)             }
  71.     ulEIDSize: Cardinal;        { Count in bytes of size of pEntryID       }
  72.     lpEntryID: Pointer;         { System-specific recipient reference      }
  73.   end;
  74.  
  75. const
  76.   MAPI_ORIG = 0;                { Recipient is message originator          }
  77.   MAPI_TO = 1;                  { Recipient is a primary recipient         }
  78.   MAPI_CC = 2;                  { Recipient is a copy recipient            }
  79.   MAPI_BCC = 3;                 { Recipient is blind copy recipient        }
  80.  
  81. type
  82.   PMapiMessage = ^TMapiMessage;
  83.   TMapiMessage = packed record
  84.     ulReserved: Cardinal;         { Reserved for future use (M.B. 0)       }
  85.     lpszSubject: LPSTR;           { Message Subject                        }
  86.     lpszNoteText: LPSTR;          { Message Text                           }
  87.     lpszMessageType: LPSTR;       { Message Class                          }
  88.     lpszDateReceived: LPSTR;      { in YYYY/MM/DD HH:MM format             }
  89.     lpszConversationID: LPSTR;    { conversation thread ID                 }
  90.     flFlags: FLAGS;               { unread,return receipt                  }
  91.     lpOriginator: PMapiRecipDesc; { Originator descriptor                  }
  92.     nRecipCount: Cardinal;        { Number of recipients                   }
  93.     lpRecips: PMapiRecipDesc;     { Recipient descriptors                  }
  94.     nFileCount: Cardinal;         { # of file attachments                  }
  95.     lpFiles: PMapiFileDesc;       { Attachment descriptors                 }
  96.   end;
  97.  
  98. const
  99.   MAPI_UNREAD = $00000001; 
  100.   MAPI_RECEIPT_REQUESTED = $00000002; 
  101.   MAPI_SENT = $00000004; 
  102.  
  103.  
  104. { Entry points. }
  105.  
  106. { flFlags values for Simple MAPI entry points. All documented flags are
  107.   shown for each call. Duplicates are commented out but remain present
  108.   for every call. }
  109.  
  110. { MAPILogon() flags. }
  111.  
  112.   MAPI_LOGON_UI = $00000001;                { Display logon UI             }
  113.   MAPI_PASSWORD_UI = $00020000;             { prompt for password only     }
  114.   MAPI_NEW_SESSION = $00000002;             { Don't use shared session     }
  115.   MAPI_FORCE_DOWNLOAD = $00001000;          { Get new mail before return   }
  116.   MAPI_ALLOW_OTHERS = $00000008;            { Make this a shared session   }
  117.   MAPI_EXPLICIT_PROFILE = $00000010;        { Don't use default profile    }
  118.   MAPI_EXTENDED = $00000020;                { Extended MAPI Logon          }
  119.   MAPI_USE_DEFAULT = $00000040;             { Use default profile in logon }
  120.  
  121.   MAPI_SIMPLE_DEFAULT = MAPI_LOGON_UI or MAPI_FORCE_DOWNLOAD or MAPI_ALLOW_OTHERS; 
  122.   MAPI_SIMPLE_EXPLICIT = MAPI_NEW_SESSION or MAPI_FORCE_DOWNLOAD or MAPI_EXPLICIT_PROFILE; 
  123.  
  124. { MAPILogoff() flags.      }
  125.  
  126.   MAPI_LOGOFF_SHARED = $00000001;           { Close all shared sessions    }
  127.   MAPI_LOGOFF_UI = $00000002;               { It's OK to present UI        }
  128.  
  129. { MAPISendMail() flags.    }
  130.  
  131. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  132. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  133.   MAPI_DIALOG = $00000008;                  { Display a send note UI       }
  134. { # define MAPI_USE_DEFAULT     0x00000040     Use default profile in logon }
  135.  
  136. { MAPIFindNext() flags.    }
  137.  
  138.   MAPI_UNREAD_ONLY = $00000020;             { Only unread messages         }
  139.   MAPI_GUARANTEE_FIFO = $00000100;          { use date order               }
  140.   MAPI_LONG_MSGID = $00004000;              { allow 512 char returned ID   }
  141.  
  142. { MAPIReadMail() flags.    }
  143.  
  144.   MAPI_PEEK = $00000080;                    { Do not mark as read.         }
  145.   MAPI_SUPPRESS_ATTACH = $00000800;         { header + body, no files      }
  146.   MAPI_ENVELOPE_ONLY = $00000040;           { Only header information      }
  147.   MAPI_BODY_AS_FILE = $00000200; 
  148.  
  149. { MAPISaveMail() flags.    }
  150.  
  151. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  152. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  153. { #define MAPI_LONG_MSGID      0x00004000  /* allow 512 char returned ID   }
  154.  
  155. { MAPIAddress() flags.     }
  156.  
  157. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  158. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  159.  
  160. { MAPIDetails() flags.     }
  161.  
  162. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  163. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  164.   MAPI_AB_NOMODIFY = $00000400;             { Don't allow mods of AB entries }
  165.  
  166. { MAPIResolveName() flags. }
  167.  
  168. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  169. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  170. { #define MAPI_DIALOG          0x00000008     Prompt for choices if ambiguous }
  171. { #define MAPI_AB_NOMODIFY     0x00000400     Don't allow mods of AB entries }
  172.  
  173. type
  174.   PFNMapiLogon = ^TFNMapiLogOn;
  175.   TFNMapiLogOn = function(ulUIParam: Cardinal; lpszProfileName: LPSTR; 
  176.     lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; 
  177.     lplhSession: PLHANDLE): Cardinal stdcall;
  178.  
  179.   PFNMapiLogOff = ^TFNMapiLogOff;
  180.   TFNMapiLogOff = function(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS;
  181.     ulReserved: Cardinal): Cardinal stdcall;
  182.  
  183.   PFNMapiSendMail = ^TFNMapiSendMail;
  184.   TFNMapiSendMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;
  185.     var lpMessage: TMapiMessage; flFlags: FLAGS;
  186.     ulReserved: Cardinal): Cardinal stdcall;
  187.  
  188.   PFNMapiSendDocuments = ^TFNMapiSendDocuments;
  189.   TFNMapiSendDocuments = function(ulUIParam: Cardinal; lpszDelimChar: LPSTR;
  190.     lpszFilePaths: LPSTR; lpszFileNames: LPSTR;
  191.     ulReserved: Cardinal): Cardinal stdcall;
  192.  
  193.   PFNMapiFindNext = ^TFNMapiFindNext;
  194.   TFNMapiFindNext = function(lhSession: LHANDLE; ulUIParam: Cardinal;
  195.     lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
  196.     ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal stdcall;
  197.  
  198.   PFNMapiReadMail = ^TFNMapiReadMail;
  199.   TFNMapiReadMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;
  200.     lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  201.     var lppMessage: PMapiMessage): Cardinal stdcall;
  202.  
  203.   PFNMapiSaveMail = ^TFNMapiSaveMail;
  204.   TFNMapiSaveMail = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  205.     var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal; 
  206.     lpszMessageID: LPSTR): Cardinal stdcall;
  207.  
  208.   PFNMapiDeleteMail = ^TFNMapiDeleteMail;
  209.   TFNMapiDeleteMail = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  210.     lpszMessageID: LPSTR; flFlags: FLAGS; 
  211.     ulReserved: Cardinal): Cardinal stdcall;
  212.  
  213.   PFNMapiFreeBuffer = ^TFNMapiFreeBuffer;
  214.   TFNMapiFreeBuffer = function(pv: Pointer): Cardinal stdcall;
  215.  
  216.   PFNMapiAddress = ^TFNMapiAddress;
  217.   TFNMapiAddress = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  218.     lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR; 
  219.     nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS; 
  220.     ulReserved: Cardinal; lpnNewRecips: PULONG; 
  221.     var lppNewRecips: PMapiRecipDesc): Cardinal stdcall;
  222.  
  223.   PFNMapiDetails = ^TFNMapiDetails;
  224.   TFNMapiDetails = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  225.     var lpRecip: TMapiRecipDesc; flFlags: FLAGS; 
  226.     ulReserved: Cardinal): Cardinal stdcall;
  227.  
  228.   PFNMapiResolveName = ^TFNMapiResolveName;
  229.   TFNMapiResolveName = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  230.     lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; 
  231.     var lppRecip: PMapiRecipDesc): Cardinal stdcall;
  232.  
  233. const
  234.   SUCCESS_SUCCESS = 0; 
  235.   MAPI_USER_ABORT = 1; 
  236.   MAPI_E_USER_ABORT                  = MAPI_USER_ABORT;
  237.   MAPI_E_FAILURE = 2; 
  238.   MAPI_E_LOGON_FAILURE = 3; 
  239.   MAPI_E_LOGIN_FAILURE               = MAPI_E_LOGON_FAILURE; 
  240.   MAPI_E_DISK_FULL = 4; 
  241.   MAPI_E_INSUFFICIENT_MEMORY = 5; 
  242.   MAPI_E_ACCESS_DENIED = 6; 
  243.   MAPI_E_TOO_MANY_SESSIONS = 8; 
  244.   MAPI_E_TOO_MANY_FILES = 9; 
  245.   MAPI_E_TOO_MANY_RECIPIENTS = 10; 
  246.   MAPI_E_ATTACHMENT_NOT_FOUND = 11;
  247.   MAPI_E_ATTACHMENT_OPEN_FAILURE = 12;
  248.   MAPI_E_ATTACHMENT_WRITE_FAILURE = 13;
  249.   MAPI_E_UNKNOWN_RECIPIENT = 14;
  250.   MAPI_E_BAD_RECIPTYPE = 15;
  251.   MAPI_E_NO_MESSAGES = 16;
  252.   MAPI_E_INVALID_MESSAGE = 17;
  253.   MAPI_E_TEXT_TOO_LARGE = 18;
  254.   MAPI_E_INVALID_SESSION = 19;
  255.   MAPI_E_TYPE_NOT_SUPPORTED = 20;
  256.   MAPI_E_AMBIGUOUS_RECIPIENT = 21;
  257.   MAPI_E_AMBIG_RECIP                 = MAPI_E_AMBIGUOUS_RECIPIENT;
  258.   MAPI_E_MESSAGE_IN_USE = 22;
  259.   MAPI_E_NETWORK_FAILURE = 23;
  260.   MAPI_E_INVALID_EDITFIELDS = 24;
  261.   MAPI_E_INVALID_RECIPS = 25;
  262.   MAPI_E_NOT_SUPPORTED = 26;
  263.  
  264.  
  265. { Delphi wrapper calls around Simple MAPI }
  266.  
  267. function MapiLogOn(ulUIParam: Cardinal; lpszProfileName: LPSTR;
  268.   lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  269.   lplhSession: PLHANDLE): Cardinal;
  270.  
  271. function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS;
  272.   ulReserved: Cardinal): Cardinal;
  273.  
  274. function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  275.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;
  276.  
  277. function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR;
  278.   lpszFilePaths: LPSTR; lpszFileNames: LPSTR; ulReserved: Cardinal): Cardinal;
  279.  
  280. function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;
  281.   lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
  282.   ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;
  283.  
  284. function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  285.   lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  286.   var lppMessage: PMapiMessage): Cardinal;
  287.  
  288. function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  289.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;
  290.   lpszMessageID: LPSTR): Cardinal;
  291.  
  292. function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  293.   lpszMessageID: LPSTR; flFlags: FLAGS;
  294.   ulReserved: Cardinal): Cardinal;
  295.  
  296. function MapiFreeBuffer(pv: Pointer): Cardinal;
  297.  
  298. function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;
  299.   lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;
  300.   nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;
  301.   ulReserved: Cardinal; lpnNewRecips: PULONG;
  302.   var lppNewRecips: PMapiRecipDesc): Cardinal;
  303.  
  304. function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;
  305.   var lpRecip: TMapiRecipDesc; flFlags: FLAGS;
  306.   ulReserved: Cardinal): Cardinal;
  307.  
  308. function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;
  309.   lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  310.   var lppRecip: PMapiRecipDesc): Cardinal;
  311.  
  312. var
  313.   MAPIDLL: string = 'MAPI32.DLL';
  314.  
  315. implementation
  316.  
  317. var
  318.   MAPIModule: HModule = 0;
  319.   LogOn: TFNMapiLogOn = nil;
  320.   LogOff: TFNMapiLogOff = nil;
  321.   SendMail: TFNMapiSendMail = nil;
  322.   SendDocuments: TFNMapiSendDocuments = nil;
  323.   FindNext: TFNMapiFindNext = nil;
  324.   ReadMail: TFNMapiReadMail = nil;
  325.   SaveMail: TFNMapiSaveMail = nil;
  326.   DeleteMail: TFNMapiDeleteMail = nil;
  327.   FreeBuffer: TFNMapiFreeBuffer = nil;
  328.   Address: TFNMapiAddress = nil;
  329.   Details: TFNMapiDetails = nil;
  330.   ResolveName: TFNMapiResolveName = nil;
  331.  
  332. procedure InitMapi;
  333. begin
  334.   if MAPIModule = 0 then
  335.     MAPIModule := LoadLibrary(PChar(MAPIDLL));
  336. end;
  337.  
  338. function MapiLogOn(ulUIParam: Cardinal; lpszProfileName: LPSTR; 
  339.   lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; 
  340.   lplhSession: PLHANDLE): Cardinal;
  341. begin
  342.   InitMapi;
  343.   if @LogOn = nil then
  344.     @LogOn := GetProcAddress(MAPIModule, 'MAPILogOn');
  345.   if @LogOn <> nil then
  346.     Result := LogOn(ulUIParam, lpszProfileName, lpszPassword, flFlags,
  347.       ulReserved, lplhSession)
  348.   else Result := 1;
  349. end;
  350.  
  351. function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS; 
  352.   ulReserved: Cardinal): Cardinal;
  353. begin
  354.   InitMapi;
  355.   if @LogOff = nil then
  356.     @LogOff := GetProcAddress(MAPIModule, 'MAPILogOff');
  357.   if @LogOff <> nil then
  358.     Result := LogOff(lhSession, ulUIParam, flFlags, ulReserved)
  359.   else Result := 1;
  360. end;
  361.  
  362. function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  363.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;
  364. begin
  365.   InitMapi;
  366.   if @SendMail = nil then
  367.     @SendMail := GetProcAddress(MAPIModule, 'MAPISendMail');
  368.   if @SendMail <> nil then
  369.     Result := SendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved)
  370.   else Result := 1;
  371. end;
  372.  
  373. function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR; 
  374.   lpszFilePaths: LPSTR; lpszFileNames: LPSTR; 
  375.   ulReserved: Cardinal): Cardinal;
  376. begin
  377.   InitMapi;
  378.   if @SendDocuments = nil then
  379.     @SendDocuments := GetProcAddress(MAPIModule, 'MAPISendDocuments');
  380.   if @SendDocuments <> nil then
  381.     Result := SendDocuments(ulUIParam, lpszDelimChar, lpszFilePaths,
  382.       lpszFileNames, ulReserved)
  383.   else Result := 1;
  384. end;
  385.  
  386. function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;
  387.   lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
  388.   ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;
  389. begin
  390.   InitMapi;
  391.   if @FindNext = nil then
  392.     @FindNext := GetProcAddress(MAPIModule, 'MAPIFindNext');
  393.   if @FindNext <> nil then
  394.     Result := FindNext(lhSession, ulUIParam, lpszMessageType,
  395.       lpszSeedMessageID, flFlags, ulReserved, lpszMessageID)
  396.   else Result := 1;
  397. end;
  398.  
  399. function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  400.   lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  401.   var lppMessage: PMapiMessage): Cardinal;
  402. begin
  403.   InitMapi;
  404.   if @ReadMail = nil then
  405.     @ReadMail := GetProcAddress(MAPIModule, 'MAPIReadMail');
  406.   if @ReadMail <> nil then
  407.     Result := ReadMail(lhSession, ulUIParam, lpszMessageID, flFlags,
  408.       ulReserved, lppMessage)
  409.   else Result := 1;
  410. end;
  411.  
  412. function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  413.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;
  414.   lpszMessageID: LPSTR): Cardinal;
  415. begin
  416.   InitMapi;
  417.   if @SaveMail = nil then
  418.     @SaveMail := GetProcAddress(MAPIModule, 'MAPISaveMail');
  419.   if @SaveMail <> nil then
  420.     Result := SaveMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved,
  421.       lpszMessageID)
  422.   else Result := 1;
  423. end;
  424.  
  425. function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  426.   lpszMessageID: LPSTR; flFlags: FLAGS;
  427.   ulReserved: Cardinal): Cardinal;
  428. begin
  429.   InitMapi;
  430.   if @DeleteMail = nil then
  431.     @DeleteMail := GetProcAddress(MAPIModule, 'MAPIDeleteMail');
  432.   if @DeleteMail <> nil then
  433.     Result := DeleteMail(lhSession, ulUIParam, lpszMessageID, flFlags,
  434.       ulReserved)
  435.   else Result := 1;
  436. end;
  437.  
  438. function MapiFreeBuffer(pv: Pointer): Cardinal;
  439. begin
  440.   InitMapi;
  441.   if @FreeBuffer = nil then
  442.     @FreeBuffer := GetProcAddress(MAPIModule, 'MAPIFreeBuffer');
  443.   if @FreeBuffer <> nil then
  444.     Result := FreeBuffer(pv)
  445.   else Result := 1;
  446. end;
  447.  
  448. function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;
  449.   lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;
  450.   nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;
  451.   ulReserved: Cardinal; lpnNewRecips: PULONG;
  452.   var lppNewRecips: PMapiRecipDesc): Cardinal;
  453. begin
  454.   InitMapi;
  455.   if @Address = nil then
  456.     @Address := GetProcAddress(MAPIModule, 'MAPIAddress');
  457.   if @Address <> nil then
  458.     Result := Address(lhSession, ulUIParam, lpszCaption, nEditFields,
  459.       lpszLabels, nRecips, lpRecips, flFlags, ulReserved, lpnNewRecips,
  460.       lppNewRecips)
  461.   else Result := 1;
  462. end;
  463.  
  464. function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;
  465.   var lpRecip: TMapiRecipDesc; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;
  466. begin
  467.   InitMapi;
  468.   if @Details = nil then
  469.     @Details := GetProcAddress(MAPIModule, 'MAPIDetails');
  470.   if @Details <> nil then
  471.     Result := Details(lhSession, ulUIParam, lpRecip, flFlags, ulReserved)
  472.   else Result := 1;
  473. end;
  474.  
  475. function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;
  476.   lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  477.   var lppRecip: PMapiRecipDesc): Cardinal;
  478. begin
  479.   InitMapi;
  480.   if @ResolveName = nil then
  481.     @ResolveName := GetProcAddress(MAPIModule, 'MAPIResolveName');
  482.   if @ResolveName <> nil then
  483.     Result := ResolveName(lhSession, ulUIParam, lpszName, flFlags,
  484.       ulReserved, lppRecip)
  485.   else Result := 1;
  486. end;
  487.  
  488. initialization
  489. finalization
  490.   if MAPIModule <> 0 then FreeLibrary(MAPIModule);
  491. end.
  492.