Customize Outlook message inbox View VC++ code

Here I am using VC++ code and OUTLOOK object model to add new column or field in outlook inbox message view.

Like other fields ( importance,subject date ....) i am going to add new custom field.

**Note...I tried a lot to add a ICON type value using bitmap like read unread mail in that column bt i couldnt...

In simple I used a text type value for this field:
Bellow two functions written :

Over view:
MicroSoft stores the Outlook view in XML form just need to get the XML and modify it.
a lots of security and other issue involved here to know morw about it go to Creating Custom Views artical of microsoft and get alot:

CConnect::AddNewViewField()
{
Outlook::_NameSpace * pNamespacePtr;
MAPIFolder *pFolderptr;
View * pViewPtr;
BSTR strXMl;
BSTR modifiedXMLSTr;
m_spApp->GetNamespace(_T("MAPI"),&pNamespacePtr);
pNamespacePtr->GetDefaultFolder(olFolderInbox , &pFolderptr);
pFolderptr->get_CurrentView(&pViewPtr);
pViewPtr->get_XML(&strXMl);
modifiedXMLSTr = CustomizeXMLString(strXMl);
pViewPtr->put_XML(modifiedXMLSTr);
pViewPtr->Save();
pViewPtr->Apply();


return 0;
}

//Its concern to use .net functionality to XML parsing

BSTR CustomizeXMLString(BSTR pbstrXML)
{
System::Xml::XmlDocument ^ XMLDocobj = gcnew System::Xml::XmlDocument();
IntPtr p(pbstrXML);
XMLDocobj->LoadXml(System::Runtime::InteropServices::Marshal::PtrToStringAuto(p));
Xml::XmlNode ^ rootObj;
rootObj = XMLDocobj->DocumentElement;
Xml::XmlElement ^ xmlElement;
Xml::XmlElement ^ xmlElement1;
// rootObj->InsertAfter(,rootObj->SelectSingleNode("column"));

xmlElement = XMLDocobj->CreateElement("column");
xmlElement1 = XMLDocobj->CreateElement("heading");
xmlElement1->InnerText = "Sanat new";
xmlElement->AppendChild(xmlElement1);
xmlElement1 = XMLDocobj->CreateElement("prop");
xmlElement1->InnerText = "http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Security";
xmlElement->AppendChild(xmlElement1);
xmlElement1 = XMLDocobj->CreateElement("type");
xmlElement1->InnerText = "string";
xmlElement->AppendChild(xmlElement1);
xmlElement1 = XMLDocobj->CreateElement("width");
xmlElement1->InnerText = "75";
xmlElement->AppendChild(xmlElement1);

rootObj->InsertAfter(xmlElement,rootObj->SelectSingleNode("column"));
if(XMLDocobj->InnerXml)
{
return (BSTR)(VOID *)System::Runtime::InteropServices::Marshal::StringToBSTR(XMLDocobj->InnerXml);
}
return NULL;
}

Comments

Popular posts from this blog

Using Java Script detect if OS is 64 bit version or 32 bit.

Get correct OS version on win 8.1 without using GetVesionEx API (deprecated )

ESENT –JET APIs to create database in Metro Style App on Windows 8