A
Aravind
I posted in the VSTO forums and was advised to post here as people with
Outlook expertise visit this forum more frequently. My environment is:
Visual Studio 2005
Outlook 2003
Windows XP SP2.
I am creating an add-in for Outlook that will pretty much replicate the Send
functionality (including ResolveNames and Check Spelling) and adds some
custom functionality (to file the sent mail in a different folder than the
sent folder or to print the sent email immediately etc.). Initially I had
thought to do this by registering for the send event (ie.
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler)
but the requirement is that the add-in must have its own button that starts
the sending process and should not interfere with the normal "Send" that
outlook provides. After a little bit of fiddling I found the way to execute
the Resolve Names and Spell check but they don't quite work the same as when
the user clicks the "Send" button (i.e. they are not seamless). I have not
been successful in trying to "Execute" the send button using the same logic.
The below code (for ex.) executes the Spell Check functionality.
MSO.CommandBar toolsmenubar = null;
toolsmenubar =
Globals.ThisApplication.ActiveInspector().CommandBars.ActiveMenuBar;
MSO.CommandBarButton spellcheckbutton = null;
if (toolsmenubar != null)
{
// try to find button
spellcheckbutton =
(MSO.CommandBarButton)toolsmenubar.FindControl(myMissing,
IDSPELLCHECKBUTTON.ToString(), myMissing, myMissing, true);
}
if (spellcheckbutton != null)
{
if (spellcheckbutton.Enabled.Equals(true))
{
try
{
spellcheckbutton.Execute();
}
catch (System.Exception ex)
{
MessageBox.Show("An error occured when trying to send this
message." + "\n" + "Error: " + ex.Message,
"Outlook Add-in", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
IDSPELLCHECKBUTTON is defined as constant 2
IDSENDBUTTON is defined as constant 2617 (I also tried 3037 for File->Send)
In the above code block if I replace IDSPELLCHECKBUTTON with IDSENDBUTTON I
get an Exception and the send does not work.
Any help in getting the Send to work using the execute will be very
appreciated. Obviously I don't want to use mailItem.Send because that way
it doesn't do the resolve names and spell check functions.
Thanks,
Aravind
Outlook expertise visit this forum more frequently. My environment is:
Visual Studio 2005
Outlook 2003
Windows XP SP2.
I am creating an add-in for Outlook that will pretty much replicate the Send
functionality (including ResolveNames and Check Spelling) and adds some
custom functionality (to file the sent mail in a different folder than the
sent folder or to print the sent email immediately etc.). Initially I had
thought to do this by registering for the send event (ie.
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler)
but the requirement is that the add-in must have its own button that starts
the sending process and should not interfere with the normal "Send" that
outlook provides. After a little bit of fiddling I found the way to execute
the Resolve Names and Spell check but they don't quite work the same as when
the user clicks the "Send" button (i.e. they are not seamless). I have not
been successful in trying to "Execute" the send button using the same logic.
The below code (for ex.) executes the Spell Check functionality.
MSO.CommandBar toolsmenubar = null;
toolsmenubar =
Globals.ThisApplication.ActiveInspector().CommandBars.ActiveMenuBar;
MSO.CommandBarButton spellcheckbutton = null;
if (toolsmenubar != null)
{
// try to find button
spellcheckbutton =
(MSO.CommandBarButton)toolsmenubar.FindControl(myMissing,
IDSPELLCHECKBUTTON.ToString(), myMissing, myMissing, true);
}
if (spellcheckbutton != null)
{
if (spellcheckbutton.Enabled.Equals(true))
{
try
{
spellcheckbutton.Execute();
}
catch (System.Exception ex)
{
MessageBox.Show("An error occured when trying to send this
message." + "\n" + "Error: " + ex.Message,
"Outlook Add-in", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
IDSPELLCHECKBUTTON is defined as constant 2
IDSENDBUTTON is defined as constant 2617 (I also tried 3037 for File->Send)
In the above code block if I replace IDSPELLCHECKBUTTON with IDSENDBUTTON I
get an Exception and the send does not work.
Any help in getting the Send to work using the execute will be very
appreciated. Obviously I don't want to use mailItem.Send because that way
it doesn't do the resolve names and spell check functions.
Thanks,
Aravind