Board index » delphi » Mapi SendMail Help

Mapi SendMail Help

Hi could someone please email me an example of using the sendmail function
in Delphi 3 - I'm probally being very stupid but i cant seem to work out
how to utilise the mapi.pas ie use the sendmail function to send a simple
message to a microsoft exchange server ie

To : Fred
From : Tim
Message : Please visit

?????

Please help

Many thanks

Tim
obe...@global.co.za

 

Re:Mapi SendMail Help


== Ursprngliche Mitteilung von "Spooky" <spo...@ghost.pop> am 22.07.98
21:20
Quote
>Hi could someone please email me an example of using the sendmail function
>in Delphi 3 - I'm probally being very stupid but i cant seem to work out
>how to utilise the mapi.pas ie use the sendmail function to send a simple
>message to a microsoft exchange server ie

>To : Fred
>From : Tim
>Message : Please visit

>?????

>Please help

>Many thanks

>Tim
>obe...@global.co.za

=== Kommentar von MSCHNELL@LUMINO (Michael Schnell) am 24.07.98 09:06

Here a test program I once wrote:

unit mapitest;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  mapi, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  sessionhandle : LHandle;

var  s1 : string = ';';
     s2 : string = 'c:\autoexec.bat;c:\autoexec.bak';
     s3 : string = 'xyz1;xyz2';
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var  err: integer;

     mess : TMAPIMessage;
     files: TMapiFileDesc;
     reci : array [0..10] of TMapiRecipDesc;

     ID0,ID1 : array [0..100] of byte;

begin

//  err:= mapilogon (0, NIL, NIL, 0, 0, @sessionhandle);
  form1.caption := format ('<%d>', [sessionhandle]);

//  err := MAPISendDocuments (0, pchar(s1), pchar(s2), pchar(s3), 0);
//  funktioniert !

  files.ulReserved        := 0;
  files.flFlags           := 0;
  files.nPosition         := 0;
  files.lpszPathName      := 'xyz';
  files.lpszFileName      := 'xyz';
  files.lpFileType        := NIL;

  reci[0].ulReserved         := 0;
  reci[0].ulRecipClass       := MAPI_TO;   //1 = "An"
  reci[0].lpszName           := 'mschnell@Marianne';
  reci[0].lpszAddress        := NIL;
  reci[0].ulEIDSize          := 0;
  reci[0].lpEntryID          := NIL;

  reci[1].ulReserved         := 0;
  reci[1].ulRecipClass       := MAPI_TO;   //1 = "An"
  reci[1].lpszName           := 'pop3:k...@khk.com';
  reci[1].lpszAddress        := NIL;
  reci[1].ulEIDSize          := 0;
  reci[1].lpEntryID          := NIL;

  mess.ulReserved         := 0;
  mess.lpszSubject        := 'Das ist das Subject';
  mess.lpszNoteText       := 'Das ist der Text'#13'Das ist mehr
text'#13'test mit simple MAPI';
  mess.lpszMessageType    := 'Messagetype';
  mess.lpszDateReceived   := '1998/05/05 05:05';
  mess.lpszConversationID := '987654321';
  mess.flFlags            := 0;
  mess.lpOriginator       := NIL;  //Nicht n?tig
  mess.nRecipCount        := 2;
  mess.lpRecips           := @(reci[0]);
  mess.nFileCount         := 0;
  mess.lpFiles            := NIL;

  err := MAPISendMail (0, 0, mess, 0, 0);

  button1.caption := format ('<%d>', [err]);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var  err: integer;
begin
  err := mapilogoff (sessionhandle, 0, 0, 0);
  button1.caption := format ('<%d>', [err]);
end;

end.

-Michael Schnell, Lumino GmbH, Krefeld, Germany.
 mailto:mschn...@lumino.de
 http://www.lumino.de

Other Threads