Link to home
Start Free TrialLog in
Avatar of CalvinDay
CalvinDay

asked on

mail problem

When I press the button, my e-mail screen shows but the mouse and tab key don't work until I press Ctrl-K. Does anybody else have this problem? Why is this?

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
  public
  end;

var
  Form1:TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  MAPISendDocuments(0,';',PChar('c:\autoexec.bat'),PChar('test'),0);
end;

end.
Avatar of inthe
inthe

mouse is fine tab key dont work though???
try this one:
its more than a 1 liner but this will send the document as well and subject + address and cc address ,:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  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

  form1.caption := format ('<%d>', [sessionhandle]);
  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;
  reci[0].lpszName          := 'Legend@Enterprise.Net';
  reci[0].lpszAddress        := NIL;
  reci[0].ulEIDSize          := 0;
  reci[0].lpEntryID          := NIL;

  reci[1].ulReserved        := 0;
  reci[1].ulRecipClass      := MAPI_TO;
  reci[1].lpszName          := 'Inthe.future@easyspace.com';
  reci[1].lpszAddress        := NIL;
  reci[1].ulEIDSize          := 0;
  reci[1].lpEntryID          := NIL;
 
  mess.ulReserved        := 0;
  mess.lpszSubject        := 'your message Subject';
  mess.lpszNoteText      := 'here is a sample'#13#10'email message'#13#10'sent using simple MAPI';
  mess.lpszMessageType    := 'Messagetype';
  mess.lpszDateReceived  := '1998/05/05 05:05';
  mess.lpszConversationID := '987654321';
  mess.flFlags            := 0;
  mess.lpOriginator      := NIL;
  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.


hope that is a help
Regards BArry
Avatar of CalvinDay

ASKER

The mouse moves but I cannot get it to click in a any fields.
sorry thats crap missed half out and when add the rest it also fails  :-(

as soon as i add the
err := MAPISendDocuments (0, pchar(s1), pchar(s2), pchar(s3), 0);
line it locks up????
inthe,
Even with your fine example, I still cannot get the mouse to move into fields or tab keys to work. It does the same as the other program. I'm still stuck.
it works fine on outlook98 ,no lockup at all ,but
bombs out on outlook express ( which unfortunatly most users have :-(
what are you using?
You guessed it. Outlook Express. It bombs on 98 and NT just the same. Is it an OE bug? It's the first time I've consistancy with MAPI.
yes i also tried on 1pc with nt and bombed out and 2 win98pcs with outlook98 no problem,1pc win98 outlook express bombed..this must be why it is "express"  ;-)
Avatar of simonet
CalvinDay,

Please download the sample application I wrote for sending mail and faxes using S-MAPI.

You can download it from
http://www.bhnet.com.br/~simonet/howtoprojs.htm

I believe your problem is related to you not having an open MAPI session at the time MAPISendDocuments is called.

YOurs,

Alex

simonet,
Using your program, when I press the send key, I get a Outlook Express send message dialog version 5.0 that is blank. Mouse and tab do not work. I press ctrl-K and get out. Then I get a second Outlook Express that is filled in. (information from your program) Again, the mouse and tab do not work. I had seen this program before (very nice I might add) and it didn't behave this way. I think this is a bug with Outlook Express version 5.0. As a matter of fact, I don't remember your program bringing up any Outlook Express dialogs. Am I right? Maybe you could check?
i also use outlook expres5 and this seems to be problem as alex program works ok an all other pcs i tried without oe5..
using outlook98 it is ok.
inthe,
Are you seeing the same problem as I describe in the comment to simonet? That is, two e-mail dialogs show up and the mouse and tab key no-worky.
I think the problem is with IE5 and OE5. Try setting MS Exchage as the default MAPI client. OE5 overrides that information at installation time.

Yours,

Alex
Calvin and Barry, people have reported this same problem before when using the program with OE5, som I am aware of it. Unfortunatly, I do not have OE5 (not IE5), so I cannot debug it under that specific environment. Sorry about that.

Yours,

Alex
msexchange is ok on nt ...
I used winsight and found that as soon as my program (above) launches the e-mail dialog, that both windows have the WS_DISABLED style. Why would anybody do this? This is why both windows are unable to receive mouse clicks and key strokes.
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i use that in conjunction with the fuller unit i posted before and so far worked on every machine i tried it on with outlook express,98, ms exchange etc..

It worked! Super job.
:-)