Re: Adding comandbar to RichText Inspector cause error.



I don't have solution for this, so I just don't show Toolbar in that case.

"Dimitry" wrote:

Hello,

I experience same problem.
So, after all, any solution? Or it just considered as a bug and will be fixed?

TIA
Dimitry.

"victor" wrote:

I wrote small javascript, so you can see this error on you machine. You can
simply create html file, insert this code it and then just open html file
with IE.
This javascript gets last item from inbox, show it and tried to add Command
Bar to it. if you send yourself Rich Text email you should see and run this
script then CommandBar.Add will fail and you'll see JavaScript alert "Error
#-2147467259". If you send Plain Text or HTML email then CommandBar.Add will
succeed and you won't see any error messages.

Here's javascript code:
<html>
<script language="javascript" type="text/javascript">
var toolBarName = "TestToolBar3";
OpenOutlookDoc()
function OpenOutlookDoc()
{
try
{
var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
// Get Inbox folder
var mailFolder = nameSpace.getDefaultFolder(6);
// Get Last Email
var mailItem = mailFolder.Items.GetLast();
mailItem.Display(0);
var inspector = mailItem.GetInspector;
// Try to add inspector to this email
inspector.CommandBars.Add(toolBarName, 0,
0, true);
}
catch(e)
{
// Display error
alert(e.name + " #" + e.number + ": " + e.message);
}
}

</script>
</html>


-----------------------------------------------------
"Dmitry Streblechenko" wrote:

Check first if the toolbar already exists
(CommandBars.Item[("TestToolBar"]), if that fails (try..catch block), call
CommandBars.Add

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

"victor" <victor@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:06763557-048A-4AC1-B661-8789B51C9CCC@xxxxxxxxxxxxxxxx
Thanks for answering my post.

I got this exception "Error HRESULT E_FAIL has been returned from a call
to
a COM component.".

Here is C# code:
public partial class ThisApplication
{
private Outlook.InspectorsClass m_OLInspectors = null;

private void ThisApplication_Startup(object sender, System.EventArgs e)
{
m_OLInspectors = (Outlook.InspectorsClass)this.Inspectors;
// Add event handler for NewInspector event
m_OLInspectors.NewInspector += new
Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(_NewInspector_EventHandler);
}

public void _NewInspector_EventHandler(Outlook.Inspector newInspector)
{
try
{
newInspector.CommandBars.Add("TestToolBar",
System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true);
}
catch (Exception exc)
{
// Exceptions always occurs when I open Rich Text emails
MessageBox.Show("Exception occured.");
}
}
...

Basically it just creates new toolbar when new inspector is created. It
works for all types of MailItems except received Rich Text MailItems (and
only if "Tools >> Options. >> Mail Format >> Use MS Word 2003 to read Rich
Text e-mail messages" is checked).



--------------------------------------------------------------------------
"Dmitry Streblechenko" wrote:

Please show your code. What is the exact error message?

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

"victor" <victor@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:86BD6EA5-FBBF-45B3-9422-FA5572A452DA@xxxxxxxxxxxxxxxx
Unfortunatly, it didn't help. I still get the same error.

"Dmitry Streblechenko" wrote:

Wait until Inspector.Activate event fires (it can fire multiple times
for
the same inspector) and try to add the command bar again.

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

"victor" <victor@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:55696191-540C-428B-8EC5-A7B10316B904@xxxxxxxxxxxxxxxx
I'm adding command bar to Inspectors using
inspector.CommandBars.Add.
It
works fine for all types of emails except Rich Text. It has
something
to
do
with WordEditor.

If I open RichText email it cause E_FAIL error ("Tools/Options/Mail
Format/Use MS Word 2003 to read Rich Text e-mail messages" should be
checked).

I tried to add command bar to both inspector.CommandBars and
wordDocument.CommandBars objects, but none of them works.

I found bunch of posts in Internet about this problem, but none of
them
tells you any way around it.
Here is some of them:
http://www.pcreview.co.uk/forums/thread-1856592.php
http://www.pcreview.co.uk/forums/thread-1856368.php
http://help.lockergnome.com/office/ing-button-word-display-rtf-messages-fails-ftopict819333.html

P.s. I use Outlook 2003 SP 2

Thanks,
Victor









.