2002 vs 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Look this piece of code for Outlook 2002:
Outlook::_Inspector* spInsp = g_ppvApplication->ActiveInspector();
Office::_CommandBars *bars = spInsp->CommandBars;
Office::CommandBar *bar = bars->ActiveMenuBar;
Office::CommandBarControls *ctrls1 = bar->Controls;
Office::CommandBarPopupPtr popm =
(Office::CommandBarPopupPtr)(ctrls1->GetItem("edit"));
Office::CommandBarControlsPtr ctrls2 = popm->Controls;
Office::_CommandBarButtonPtr btn1 =
(Office::_CommandBarButtonPtr)(ctrls2->GetItem("edit message"));
Office::_CommandBarButtonPtr btn2 =
(Office::_CommandBarButtonPtr)(ctrls2->GetItem("select all"));
Office::_CommandBarButtonPtr btn3 =
(Office::_CommandBarButtonPtr)(ctrls2->GetItem("paste"));
btn1->Execute();
btn2->Execute();

HGLOBAL hData;
LPVOID pData;
BOOL r;
r = OpenClipboard(NULL);
UINT hRTF = RegisterClipboardFormat(CF_RTF); //("Rich Text Format")
r = EmptyClipboard();
hData = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, strPlain.length() + 1);
pData = GlobalLock(hData);
strcpy((LPSTR)pData, rtfData);
GlobalUnlock(hData);
HANDLE h = SetClipboardData(hRTF, hData);
r = CloseClipboard();

bool b = btn3->Enabled;
if (b)
btn3->Execute();
else
{
MessageBox(NULL, "Paste Execute", "Error", MB_OK);
}

It works for Outlook 2002, but if I modify it for Outlook 2003 it doesn't
work: the "select all" button seems to be disabled and the same is for the
paste button.
Does anyone know if these buttons has been disabled in Outlook 2003 to avoid
security problem?

As you can see this method could be used in order to create an RTF mail
pasting the data directly in the mail body, without using the outlook body
property which doesn't support the RTF. In Outlook 2002 works!

Thanks in advance.
Sektor
 
Are you using the same kind of editor in both versions (built-in vs Word)?
Note that the Word editor will disable some of its menu items if the
inspector does not have the focus.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Thanks Dmitry,
When I tried the plug-in with 2002 the focus was on the inspector (the
plug-in was activated by a button in the inspector), but when I tried with
2003 the focus was not on the inspector (plug-in activated by a pop-up
menu).
So, as you suggested, I put the focus on the inspector (spInsp->Activate()):
the buttons "select all" and "paste" are now enabled.

The problem is the same either I use the built-in editor or Word editor and
the solution is just the same: the inspector must have the focus (as Dmitry
said).

Bye
Sektor
 
Back
Top