Board index » delphi » Mail Item OnClose event

Mail Item OnClose event


2008-04-07 10:23:54 PM
delphi66
I use this code to create and display an outlook e-mail
private
FOutlook : TOutlookApplication;
FOutlookNameSpace : OleVariant;
FMailItem : _MailItem;
procedure TdlgOle.btnEmailClick(Sender: TObject);
begin
FActiveApplication := aaOutlook;
FOutlook := TOutlookApplication.Create(Self);
FOutlook.OnItemSend := OutlookApplication1ItemSend;
FOutlook.Connect;
FOutlookNameSpace := FOutlook.GetNamespace('MAPI');
FOutlookNameSpace.Logon(EmptyParam, EmptyParam, False, True);
FMailItem := FOutlook.CreateItem(olMailItem) as _MailItem;
FMailItem.Display(false);
end;
If the user closes the e-mail without sending it, I want to caue some code
to run. TMailItem has and OnClose event, but how do I link FMailItem to this
event? alternatively, is there another means of creating a mil item which
would resolve my problem?
 
 

Re:Mail Item OnClose event

Instead of declaring FMailItem as _MailItem, use the Delphi wrapper
(TMailItem?) - you are already using TOutlookApplication.
--
Dmitry Streblechenko (MVP)
www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Paul Tugwell" <XXXX@XXXXX.COM>writes
Quote
I use this code to create and display an outlook e-mail

private
FOutlook : TOutlookApplication;
FOutlookNameSpace : OleVariant;
FMailItem : _MailItem;

procedure TdlgOle.btnEmailClick(Sender: TObject);
begin
FActiveApplication := aaOutlook;
FOutlook := TOutlookApplication.Create(Self);
FOutlook.OnItemSend := OutlookApplication1ItemSend;
FOutlook.Connect;
FOutlookNameSpace := FOutlook.GetNamespace('MAPI');
FOutlookNameSpace.Logon(EmptyParam, EmptyParam, False, True);
FMailItem := FOutlook.CreateItem(olMailItem) as _MailItem;
FMailItem.Display(false);
end;

If the user closes the e-mail without sending it, I want to caue some code
to run. TMailItem has and OnClose event, but how do I link FMailItem to
this event? alternatively, is there another means of creating a mil item
which would resolve my problem?