Iterating all the contacts folder of outlook


Joined
Dec 14, 2012
Messages
2
Reaction score
0
Hi All
I am VC++ developer and trying to Automate Microsoft Outlook using VC++ and got stucked at one point so need your help indeed.

Expecting your reply for my question.:(

what i want to achieve through VC++ code is :-

I have few contacts in my application and i want to transfer them to outlook. And in outlook itself there are 3 to 5 user created contacts folder.
so first time i will ask user to pic the contact folder and once he chosen the contact folder, i will store the path of chosen contact folder in an .ini file
So next time when he transfers the contact I will not ask him to choose the folder again via the same code, instead i will transfer the contact to the same old contact folder, whose path i have saved in the .ini file.

so what i wanted to implement is to iterate all contact folders present in the outlook and get their path through pFolder->GetFullFolderPath(); function and compare it with saved path if found then i can use that folder object for moving my contact exactly there
something like this
pItem->Save();
pItem->Move(pFolder);

Partial Code snippet Below in VC++

_ApplicationPtr pApp;
_ItemsPtr pItems;
MAPIFolderPtr pFolder, pFolderChld;
_ContactItemPtr pContact;
HRESULT hr;

try
{
hr=pApp.CreateInstance(__uuidof(Application));

if (FAILED(hr))
{
MsageBox("Unable to instantiate Outlook.","Outlook Error",MB_OK);
return;
}
if(m_Option.GetCheck()) //default outlook contacts folder
{
pFolder=pApp->GetNamespace(_bstr_t("MAPI"))->GetDefaultFolder(olFolderContacts);
if (pFolder==NULL)
{
MessageBox("Could not find default contacts folder.","Outlook Error");
return;
}
}
else //display folder selection window
{
pFolder = pApp->GetNamespace(_bstr_t("MAPI"))->PickFolder();
if (pFolder==NULL)
return;
if (pFolder->GetDefaultItemType()!=olContactItem)
{
MessageBox("Select folder is not a Contact folder.","Outlook Contacts");
return;
}
else
{
BSTR bsPath = pFolder->GetFullFolderPath();
}
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top