Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

mail problem

Posted on 1999-07-19
21
Medium Priority
?
438 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:CalvinDay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 7
  • 3
21 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 1389669
mouse is fine tab key dont work though???
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389670
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
0
 
LVL 2

Author Comment

by:CalvinDay
ID: 1389671
The mouse moves but I cannot get it to click in a any fields.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 17

Expert Comment

by:inthe
ID: 1389672
sorry thats crap missed half out and when add the rest it also fails  :-(

0
 
LVL 17

Expert Comment

by:inthe
ID: 1389673
as soon as i add the
err := MAPISendDocuments (0, pchar(s1), pchar(s2), pchar(s3), 0);
line it locks up????
0
 
LVL 2

Author Comment

by:CalvinDay
ID: 1389674
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.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389675
it works fine on outlook98 ,no lockup at all ,but
bombs out on outlook express ( which unfortunatly most users have :-(
what are you using?
0
 
LVL 2

Author Comment

by:CalvinDay
ID: 1389676
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.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389677
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"  ;-)
0
 
LVL 15

Expert Comment

by:simonet
ID: 1389678
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

0
 
LVL 2

Author Comment

by:CalvinDay
ID: 1389679
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?
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389680
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.
0
 
LVL 2

Author Comment

by:CalvinDay
ID: 1389681
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.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1389682
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
0
 
LVL 15

Expert Comment

by:simonet
ID: 1389683
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
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389684
msexchange is ok on nt ...
0
 
LVL 2

Author Comment

by:CalvinDay
ID: 1389685
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.
0
 
LVL 17

Accepted Solution

by:
inthe earned 120 total points
ID: 1389686
ok the answer is because the window in effect has no parent therefore it is modal but disabled.

if you give it a parent  like so:

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

it all is ok.
Regards Barry


0
 
LVL 17

Expert Comment

by:inthe
ID: 1389687
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..

0
 
LVL 2

Author Comment

by:CalvinDay
ID: 1389688
It worked! Super job.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1389689
:-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question