hooking the insert-File menu command (add attachment) in outlook 2003 (c# add in)

S

semedao

Hi all,
I try to replace the regular add file dialog that open when clicking in the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id, myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new attachment.

and then I register to it's _CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all versions
to handle it?

and also , how can I catch the insert attachment button that's appear in the
side of the subject ?
 
D

Dmitry Streblechenko

It looks like Outlook is using id = 1079 in Outlook 2002 and id = 777 in
Outlook 2003 (both Word editor, didn't check any otherversions).
To make sure your code only depends on the Outlook version rather than a
locale, do not use the menu names, use CommandBars.FindControl instead and
specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
S

semedao

What I determined is other thing
when using word as the email editor the value changed... (777 ?)
using without it - 1079
:)


Dmitry Streblechenko said:
It looks like Outlook is using id = 1079 in Outlook 2002 and id = 777 in
Outlook 2003 (both Word editor, didn't check any otherversions).
To make sure your code only depends on the Outlook version rather than a
locale, do not use the menu names, use CommandBars.FindControl instead and
specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
Hi all,
I try to replace the regular add file dialog that open when clicking in
the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id, myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new attachment.

and then I register to it's _CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language
version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all
versions
to handle it?

and also , how can I catch the insert attachment button that's appear in
the
side of the subject ?
 
D

Dmitry Streblechenko

Here you go. Call the Inspector.IsWordMail method and branch your code
appropriately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
What I determined is other thing
when using word as the email editor the value changed... (777 ?)
using without it - 1079
:)


Dmitry Streblechenko said:
It looks like Outlook is using id = 1079 in Outlook 2002 and id = 777 in
Outlook 2003 (both Word editor, didn't check any otherversions).
To make sure your code only depends on the Outlook version rather than a
locale, do not use the menu names, use CommandBars.FindControl instead
and specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
Hi all,
I try to replace the regular add file dialog that open when clicking in
the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id, myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new attachment.

and then I register to it's _CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language
version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all
versions
to handle it?

and also , how can I catch the insert attachment button that's appear in
the
side of the subject ?
 
S

semedao

thanks , now the next problem is that I used findcontrol/s and register to
the click event
when choose from insert->file or from the toolbar clicking on the down arrow
near the attachment and than choose "file.." it's work
but if I click directly on the attachment icon on the toolbar it's not work.
I saw that the attachment icon have the same id (777 - wordmail) as the
other menu and drop down toolbar options !
so whay it's not working ?
thanks
Dmitry Streblechenko said:
Here you go. Call the Inspector.IsWordMail method and branch your code
appropriately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
What I determined is other thing
when using word as the email editor the value changed... (777 ?)
using without it - 1079
:)


Dmitry Streblechenko said:
It looks like Outlook is using id = 1079 in Outlook 2002 and id = 777 in
Outlook 2003 (both Word editor, didn't check any otherversions).
To make sure your code only depends on the Outlook version rather than a
locale, do not use the menu names, use CommandBars.FindControl instead
and specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hi all,
I try to replace the regular add file dialog that open when clicking in
the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id,
myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new attachment.

and then I register to it's _CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language
version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all
versions
to handle it?

and also , how can I catch the insert attachment button that's appear
in the
side of the subject ?
 
D

Dmitry Streblechenko

Because it is broken :) ?
The attachment icon in the Word editor is not a real CommandBarButton
conrol - you cannot access any buttons there. The "Envelope" toolbar exposes
a single control that contains everything else.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
thanks , now the next problem is that I used findcontrol/s and register to
the click event
when choose from insert->file or from the toolbar clicking on the down
arrow near the attachment and than choose "file.." it's work
but if I click directly on the attachment icon on the toolbar it's not
work.
I saw that the attachment icon have the same id (777 - wordmail) as the
other menu and drop down toolbar options !
so whay it's not working ?
thanks
Dmitry Streblechenko said:
Here you go. Call the Inspector.IsWordMail method and branch your code
appropriately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
What I determined is other thing
when using word as the email editor the value changed... (777 ?)
using without it - 1079
:)


It looks like Outlook is using id = 1079 in Outlook 2002 and id = 777
in Outlook 2003 (both Word editor, didn't check any otherversions).
To make sure your code only depends on the Outlook version rather than
a locale, do not use the menu names, use CommandBars.FindControl
instead and specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hi all,
I try to replace the regular add file dialog that open when clicking
in the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id,
myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new attachment.

and then I register to it's _CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language
version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all
versions
to handle it?

and also , how can I catch the insert attachment button that's appear
in the
side of the subject ?
 
S

semedao

sorry but I didn't understand "The "Envelope" toolbar exposes
a single control that contains everything else" , ok , it's not a
commandbarbutton , but there is no any other way to access it?
or if there is not some api , maybe by windows hooking ?
Dmitry Streblechenko said:
Because it is broken :) ?
The attachment icon in the Word editor is not a real CommandBarButton
conrol - you cannot access any buttons there. The "Envelope" toolbar
exposes a single control that contains everything else.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
thanks , now the next problem is that I used findcontrol/s and register
to the click event
when choose from insert->file or from the toolbar clicking on the down
arrow near the attachment and than choose "file.." it's work
but if I click directly on the attachment icon on the toolbar it's not
work.
I saw that the attachment icon have the same id (777 - wordmail) as the
other menu and drop down toolbar options !
so whay it's not working ?
thanks
Dmitry Streblechenko said:
Here you go. Call the Inspector.IsWordMail method and branch your code
appropriately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

What I determined is other thing
when using word as the email editor the value changed... (777 ?)
using without it - 1079
:)


It looks like Outlook is using id = 1079 in Outlook 2002 and id = 777
in Outlook 2003 (both Word editor, didn't check any otherversions).
To make sure your code only depends on the Outlook version rather than
a locale, do not use the menu names, use CommandBars.FindControl
instead and specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hi all,
I try to replace the regular add file dialog that open when clicking
in the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id,
myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new attachment.

and then I register to it's _CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language
version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all
versions
to handle it?

and also , how can I catch the insert attachment button that's appear
in the
side of the subject ?
 
D

Dmitry Streblechenko

No, there is no way to access controls on the Envelope toolbar other than
simulate mouse clicks using the mouse_event() Windows API function.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
sorry but I didn't understand "The "Envelope" toolbar exposes
a single control that contains everything else" , ok , it's not a
commandbarbutton , but there is no any other way to access it?
or if there is not some api , maybe by windows hooking ?
Dmitry Streblechenko said:
Because it is broken :) ?
The attachment icon in the Word editor is not a real CommandBarButton
conrol - you cannot access any buttons there. The "Envelope" toolbar
exposes a single control that contains everything else.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
thanks , now the next problem is that I used findcontrol/s and register
to the click event
when choose from insert->file or from the toolbar clicking on the down
arrow near the attachment and than choose "file.." it's work
but if I click directly on the attachment icon on the toolbar it's not
work.
I saw that the attachment icon have the same id (777 - wordmail) as the
other menu and drop down toolbar options !
so whay it's not working ?
thanks
Here you go. Call the Inspector.IsWordMail method and branch your code
appropriately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

What I determined is other thing
when using word as the email editor the value changed... (777 ?)
using without it - 1079
:)


It looks like Outlook is using id = 1079 in Outlook 2002 and id = 777
in Outlook 2003 (both Word editor, didn't check any otherversions).
To make sure your code only depends on the Outlook version rather
than a locale, do not use the menu names, use CommandBars.FindControl
instead and specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hi all,
I try to replace the regular add file dialog that open when clicking
in the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id,
myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new
attachment.

and then I register to it's
_CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language
version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all
versions
to handle it?

and also , how can I catch the insert attachment button that's
appear in the
side of the subject ?
 
S

semedao

thanks
Dmitry Streblechenko said:
No, there is no way to access controls on the Envelope toolbar other than
simulate mouse clicks using the mouse_event() Windows API function.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

semedao said:
sorry but I didn't understand "The "Envelope" toolbar exposes
a single control that contains everything else" , ok , it's not a
commandbarbutton , but there is no any other way to access it?
or if there is not some api , maybe by windows hooking ?
Dmitry Streblechenko said:
Because it is broken :) ?
The attachment icon in the Word editor is not a real CommandBarButton
conrol - you cannot access any buttons there. The "Envelope" toolbar
exposes a single control that contains everything else.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

thanks , now the next problem is that I used findcontrol/s and register
to the click event
when choose from insert->file or from the toolbar clicking on the down
arrow near the attachment and than choose "file.." it's work
but if I click directly on the attachment icon on the toolbar it's not
work.
I saw that the attachment icon have the same id (777 - wordmail) as the
other menu and drop down toolbar options !
so whay it's not working ?
thanks
Here you go. Call the Inspector.IsWordMail method and branch your code
appropriately.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

What I determined is other thing
when using word as the email editor the value changed... (777 ?)
using without it - 1079
:)


It looks like Outlook is using id = 1079 in Outlook 2002 and id =
777 in Outlook 2003 (both Word editor, didn't check any
otherversions).
To make sure your code only depends on the Outlook version rather
than a locale, do not use the menu names, use
CommandBars.FindControl instead and specify the control id:

set btn = inspector.commandbars.findcontrol( ,777)
btn.execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Hi all,
I try to replace the regular add file dialog that open when
clicking in the
Attach button.
I used code that :
1. get fired whenever I open new Email form (NewInspector)
2. get the CommandBar using
InsertCommandBar = Inspector.CommandBars["Insert"];

3. using

(CommandBarButton)InsertCommandBar.FindControl(myMissing, id,
myMissing,
myMissing, true);

to get the CommandBarButton that is clicked to insert new
attachment.

and then I register to it's
_CommandBarButtonEvents_ClickEventHandler

it's work well when the id paramenter whas 1079

than in other outlook languges versions , or other windows language
version
it's stop to work because or the :

InsertCommandBar = Inspector.CommandBars["Insert"];

statement return null , or the id was not 1079....

my question...

how can I determine for the correct values that are the same in all
versions
to handle it?

and also , how can I catch the insert attachment button that's
appear in the
side of the subject ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top