problem with event OnNewMail

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

problem with event OnNewMail
 
karim




Posts: 22
Joined: 2005-11-30
Hi,
I make addin for outlook 2003 with delphi 6

I try to use event OnNewMail and don't work;
When i click in new mail i don't show my message

And event OnItemSend works perfectly :D

.....
procedure DoEnvoyerMessage (ASender: TObject; var Item: Olevariant; var Cancel: Olevariant);
procedure DoNouveauMessage(ASender: TObject);
.....


procedure TAddInModule.adxCOMAddInModuleAddInInitialize(Sender: TObject);
begin

....
Application.Handle := GetActiveWindow;
OutlookApp.OnItemSend := DoEnvoyerMessage;
OutlookApp.OnNewMail := DoNouveauMessage;

...
end;

procedure TAddInModule.DoNouveauMessage(ASender: TObject);
begin
showmessage('Hello');
end;



procedure TAddInModule.adxCOMAddInModuleAddInFinalize(Sender: TObject);
begin
Application.Handle := 0;
OutlookApp.OnItemSend := nil,
OutlookApp.OnNewMail := nil;
FExplorersList.Free;
if Assigned(FExplorers) then FreeAndNil(FExplorers);

end;
Posted 15 Dec, 2005 06:11:22 Top
Dmitry Kostochko


Add-in Express team


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

I think you have choosen the wrong event. See the description of the OnNewMail event below. Try to use the TAddInModule.OnOLNewInspector, TAddInModule.OnOLInspectorActivate or TMailItem.OnOpen events.

NewMail event

Description
Occurs when one or more new e-mail messages are received in the Inbox.

Remarks
The NewMail event is useful for scenarios in which you want to be notified when a new e-mail message arrives. If you want to process items that arrive in the Inbox, consider using the ItemAdd event on the collection of items in the Inbox. The ItemAdd event passes a reference to each item that is added to a folder.

Posted 15 Dec, 2005 07:28:49 Top
karim




Posts: 22
Joined: 2005-11-30
Thanks a lot it's exactely what i want.
I have a last question.
In This event i want to hide AddCommand but it's Add office because when
"Use Microsoft Office Word to edit e-mail messages" option on create a new mail i have my toolbar for office.


This code works but i don't undertand howto detect if my commandbar for office is exist or not if is installed or not.

....
const
CommandBarControlOffice = 'Office';
.......

procedure TAddInModule.adxCOMAddInModuleOLNewInspector(ASender: TObject;
const Inspector: _Inspector);
var
i : integer;
begin
if not Inspector.IsWordMail then exit;
for i := 1 to Inspector.CommandBars.Item[CommandBarControlOffice].Controls.Count do
begin
Inspector.CommandBars.Item[CommandBarControlOffice].Set_Visible(false);
end;
end;
Posted 15 Dec, 2005 10:07:32 Top
Dmitry Kostochko


Add-in Express team


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

Ok, it seems now I understand your goal. Try to use the TadxOLInspectorCommandBar.OnBeforeAdd event.


procedure TAddInModule.OnBeforeAdd(CmdBar: TadxOLInspectorCommandBar; Inspector: Outlook2000._Inspector; var Cancel: boolean);
begin
  Cancel := Inspector.IsWordMail;
end;


Posted 15 Dec, 2005 10:50:50 Top
karim




Posts: 22
Joined: 2005-11-30
Hi Dmitry,
It's not this because the Commandbar that I want to hide it not
commandbar in outlook it's different toolbar in different Addins.

I resolve my problem with this code.

but I do not know if it is the good solution.


procedure TAddInModule.adxCOMAddInModuleOLNewInspector(ASender: TObject;
const Inspector: _Inspector);

Procedure FindMyCmdBar;
var
i : Integer;
begin
for i := 1 to Inspector.CommandBars.Count do
begin
if Inspector.CommandBars[i].Name = CommandBarControlNovaxelOffice then
begin
Inspector.CommandBars[i].Set_Visible(false);
break;
end;
end;
end;

begin
if not Inspector.IsWordMail then exit;
FindMyCmdBar;
end;
Posted 16 Dec, 2005 04:43:52 Top
Dmitry Kostochko


Add-in Express team


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

I think if the code works, it is a good solution.

Posted 16 Dec, 2005 08:05:01 Top
karim




Posts: 22
Joined: 2005-11-30
Hi Dmity,

It works fine in outlook 2003.

But not in outoolk 2000 and 2002.

When i try to debug i can go to the procedure

procedure TAddInModule.adxCOMAddInModuleOLNewInspector(ASender: TObject;
const Inspector: _Inspector);
Posted 19 Dec, 2005 04:52:32 Top
Dmitry Kostochko


Add-in Express team


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

When i try to debug i can go to the procedure

Did you mean: "can't go"?
Do you use MS Word as a default email editor in these Outlook versions?

Posted 19 Dec, 2005 07:42:55 Top
karim




Posts: 22
Joined: 2005-11-30
Hi,

It works fine in outlook 2003.
It works fine in outlook 2002 (I make a mistake).

but with outlook 2000 i can't go to the procedure
procedure TAddInModule.adxCOMAddInModuleOLNewInspector(ASender: TObject;
const Inspector: _Inspector);

When i click on newmail or transfert but i can with 2002 and 2003.


I try with w2000 sp4 and with office 2000 SR-1.

Thanks.



Posted 19 Dec, 2005 09:25:30 Top
Dmitry Kostochko


Add-in Express team


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

Do you use MS Word as a default email editor in Outlook 2000? Also, I would recommend you installing SP-3 for Outlook 2000. Also, see the 2 links below describing bugs with Outlook 2000 SR-1.

http://support.microsoft.com/?kbid=317944
http://support.microsoft.com/?kbid=317975

Posted 19 Dec, 2005 11:35:00 Top