Anton_

I use following C# code for opening mapi urls (System.ItemUrl element) that I've got through WDS API.

System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(itemUrl);//itemUrl is string like "mapi://{S-1-5-21-1637761892-2229936158-1165770529-1000}/Personal Folders($f89c2bd7)/0/Inbox/ ""

info.UseShellExecute = true;

System.Diagnostics.Process res = System.Diagnostics.Process.Start(info)

This works fine on Windows XP and Windows Server 2003 but produces "Unspecified error" on Vista with Outlook 2007 installed (with Windows Mail it works fine).

Could someone explain me how to open such urls for Outlook on Vista

Why was shell open action behaviour changed on Vista

Thanks,

Anton.



Re: Windows Desktop Search Development How to open mapi urls returned from WDS on Vista

Eric Wolz - MSFT

This functionality was broken in the Vista release. This issue has been addressed and fixed and will be made available in a future vista update release. In Vista, the default verb is not returned correctly. You can work around this by querying the context menu directly for the "open" verb and invoking the command.

Code Snippet

HRESULT InvokeDefaultVerb(IContextMenu *pcm)

{

PCSTR pszVerb = "open";

HMENU hmenu = CreatePopupMenu();

if (hmenu)

{

if (SUCCEEDED(pcm->QueryContextMenu(hmenu, 0, 1, 0x7fff, CMF_DEFAULTONLY)))

{

UINT idCmd = GetMenuDefaultItem(hmenu, MF_BYCOMMAND, 0);

if ((UINT)-1 != idCmd)

{

pszVerb = (PCSTR)MAKEINTRESOURCE(idCmd - 1);

}

}

DestroyMenu(hmenu);

}

CMINVOKECOMMANDINFOEX ici = { sizeof(ici) };

ici.lpVerb = pszVerb;

ici.nShow = SW_NORMAL;

return pcm->InvokeCommand((LPCMINVOKECOMMANDINFO)&ici);

}

// shell item based shell programming model

//

// use this to work around a bug in the "mapi:" protocol handler that makes it not

// possible to use ShellExecute() with those items. we are investigating getting that fix

// into SP1

HRESULT ExecuteItemWithContextMenu(PCWSTR pszItem)

{

IShellItem2 *psi;

HRESULT hr = SHCreateItemFromParsingName(pszItem, NULL, IID_PPV_ARGS(&psi));

if (SUCCEEDED(hr))

{

IContextMenu *pcm;

hr = psi->BindToHandler(NULL, BHID_SFUIObject, IID_PPV_ARGS(&pcm));

if (SUCCEEDED(hr))

{

hr = InvokeDefaultVerb(pcm);

pcm->Release();

}

psi->Release();

}

return hr;

}