outlook ItemSend event and delphi 6

Add-in Express™ Support Service
That's what is more important than anything else

outlook ItemSend event and delphi 6
 
karim




Posts: 22
Joined: 2005-11-30
Hi,
Do you have and example for Delphi 6 same

How to handle the ItemSend event of MS Outlook
Download adxht-304-d7.zip (Delphi 7)

Because the events in your example and delphi 7 is
procedure TAddInModule.DoItemSend(ASender: TObject; const Item: IDispatch;
var Cancel: WordBool);

With delphi 6 i can't use this parametre i try this
procedure TAddInModule.DoItemSend(ASender: TObject; var Item: Olevariant; var Cancel: Olevariant);

But it's not correct because when i can't implement this code
Because Item is Olevariant type and not IDispatch


var
Mail: MailItem;
begin
if Assigned(Item) then
begin
Item.QueryInterface(IID__MailItem, Mail);
if Assigned(Mail) then
try
// TODO

ShowMessage(Mail.Body);

finally
Mail := nil;
end;
end;


Thanks.




Posted 08 Dec, 2005 09:16:50 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Karim,

See the code below:

procedure TAddInModule.DoItemSend(ASender: TObject; var Item: OleVariant; var Cancel: OleVariant); 
var
  Mail: MailItem;
begin
  if Assigned(TVarData(Item).VDispatch) then begin
    IDispatch(TVarData(Item).VDispatch).QueryInterface(IID__MailItem, Mail);
    if Assigned(Mail) then
      try
        // TODO

        ShowMessage(Mail.Body);

      finally
        Mail := nil;
      end;
  end;
end;
Posted 08 Dec, 2005 09:52:15 Top
Guest


Guest


Thanks a lot, Dmitry.

I have two another questions.

1) My showmessage((Mail.Body) is in background and not in front.
can i put my showmessage in front ?

2) Why if i compose i new message mail.SenderName is Empty ?
Posted 08 Dec, 2005 10:49:09 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Karim,

1) Try the following code:

uses Windows, Forms;

var
  SaveHandle: HWND;
begin
  // ...
  SaveHandle := Application.Handle;
  Application.Handle := GetActiveWindow;
  ShowMessage('');
  Application.Handle := SaveHandle;
  // ...
end;


2) Because the message was not sent.

Posted 08 Dec, 2005 11:38:44 Top
Guest


Guest


Hello,

1) this methode don't work.
I can't put showmessage box in front.


For resolve my problem i create a new form

In my main progamm i have this code

if not Assigned(FMsgBox) then
Application.CreateForm(TFMsgBox, FMsgBox);
FMsgBox.Show;
Application.BringToFront;

while WaitOk do begin
Application.ProcessMessages;
end;


I Can't use FMsgBox.showmodal because i have same problem
i create variable global name waitOk in TFMsgBox.Button1Click(Sender: TObject);

2) How can i get the name or emailadress from composer.

















Posted 09 Dec, 2005 05:22:42 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Guest,

1) Can you please have a look at our examples? I hope they will help you.
http://www.add-in-express.com/free-addins/delphi-outlook-addin.php

2) I think you can get some information from the CurrentUser property of the Namespace interface (OutlookApp.GetNamespace('MAPI').CurrentUser).


Posted 09 Dec, 2005 09:57:45 Top
Karim


Guest


Thank you for your assistance.
Posted 12 Dec, 2005 09:04:08 Top