Einzelnen Beitrag anzeigen

Gruber_Hans_12345

Registriert seit: 14. Aug 2004
1.436 Beiträge
 
Delphi 2007 Professional
 
#3

Re: Eigene (Simple) MAPI32.DLL mit Delphi schreiben

  Alt 22. Nov 2006, 15:56
dpr der dll

Delphi-Quellcode:
library MyMAPI;

uses
  SysUtils,
  Windows,
  Classes,
  Dialogs,
  main in 'main.pas';

{$R *.res}

exports MAPILogon name 'MAPILogon';
exports MAPILogoff name 'MAPILogoff';
exports MAPISendMail name 'MAPISendMail';
exports MAPISendDocuments name 'MAPISendDocuments';
exports MAPIFindNext name 'MAPIFindNext';
exports MAPIReadMail name 'MAPIReadMail';
exports MAPISaveMail name 'MAPISaveMail';
exports MAPIDeleteMail name 'MAPIDeleteMail';
exports MAPIFreeBuffer name 'MAPIFreeBuffer';
exports MAPIAddress name 'MAPIAddress';
exports MAPIDetails name 'MAPIDetails';
exports MAPIResolveName name 'MAPIResolveName';
exports GetMapiDllVersion name 'GetMapiDllVersion';

procedure DllMain(reason: integer);
begin
    case reason of
        DLL_PROCESS_ATTACH:
            begin
// ShowMEssage('Attach');
    ExitCode := 0;
            end;
        DLL_PROCESS_DETACH :
            begin
// ShowMEssage('Detach');
    ExitCode := 0;
            end;
    end;
    ExitCode := 0;
end;

begin
    DllProc := @DllMain;
    DllProc(DLL_PROCESS_ATTACH);
end.
main.pas

Delphi-Quellcode:
unit main;

interface

uses
    Windows
    , Dialogs
    , MAPI
    ;

  
function MAPILogon(ulUIParam: Cardinal; lpszProfileName: LPSTR; lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; lplhSession: PLHANDLE): Cardinal; stdcall;
function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;
function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal; var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;
function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR; lpszFilePaths: LPSTR; lpszFileNames: LPSTR; ulReserved: Cardinal): Cardinal;stdcall;
function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;
        lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
        ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;stdcall;
function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;
        lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
        var lppMessage: PMapiMessage): Cardinal;stdcall;
function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;
        var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;
        lpszMessageID: LPSTR): Cardinal;stdcall;
function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;
        lpszMessageID: LPSTR; flFlags: FLAGS;
        ulReserved: Cardinal): Cardinal;stdcall;
function MapiFreeBuffer(pv: Pointer): Cardinal;stdcall;
function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;
        lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;
        nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;
        ulReserved: Cardinal; lpnNewRecips: PULONG;
        var lppNewRecips: PMapiRecipDesc): Cardinal; stdcall;
function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;
        var lpRecip: TMapiRecipDesc; flFlags: FLAGS;
        ulReserved: Cardinal): Cardinal; stdcall;
function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;
        lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
        var lppRecip: PMapiRecipDesc): Cardinal; stdcall;
function GetMapiDllVersion : Cardinal; stdcall;

implementation


//******************************************************************************

//******************************************************************************

function GetMapiDllVersion : Cardinal; stdcall;
begin
    MessageBeep(0);

    ShowMessage('GetDLLVersion');
    Result := 97;
end;


function MAPILogon(ulUIParam: Cardinal; lpszProfileName: LPSTR; lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; lplhSession: PLHANDLE): Cardinal; stdcall;
begin
    MessageBeep(0);

    ShowMessage('Logon');
    Result := SUCCESS_SUCCESS
end;

function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;
begin
    MessageBeep(0);

    ShowMessage('Logoff');
    Result := SUCCESS_SUCCESS
end;

function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal;
    var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;
begin
// ShowMessage('SendMail');

    SendMAPIMail(lpMessage);
    Result := 1;
end;

function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR;
  lpszFilePaths: LPSTR; lpszFileNames: LPSTR; ulReserved: Cardinal): Cardinal; stdcall;
begin
// MessageBeep(0);

    {
    ShowMessage('SendDocuments : Deli : "'+lpszDelimChar+'"'+#13+#10+
        'FilePAth : "'+lpszFilePaths+'"'+#13+#10+
        'lpszFileNames : "'+lpszFileNames+'"'
    );
    }

    SendMAPIDocuments(lpszDelimChar, lpszFilePaths, lpszFileNames);
    Result := SUCCESS_SUCCESS;
end;

function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;
  lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
  ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  var lppMessage: PMapiMessage): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;
  lpszMessageID: LPSTR): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  lpszMessageID: LPSTR; flFlags: FLAGS;
  ulReserved: Cardinal): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

function MapiFreeBuffer(pv: Pointer): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;
  lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;
  nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;
  ulReserved: Cardinal; lpnNewRecips: PULONG;
  var lppNewRecips: PMapiRecipDesc): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;
  var lpRecip: TMapiRecipDesc; flFlags: FLAGS;
  ulReserved: Cardinal): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;
  lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  var lppRecip: PMapiRecipDesc): Cardinal;
begin
    Result := MAPI_E_FAILURE;
end;

end.
aber ohne gewähr, bei mir hat es mal gefunkt so, war nur ein test (deswegen die vielen Showmessages )
Gruss Hans

2B or not 2B, that is FF
  Mit Zitat antworten Zitat