Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook
Iterating all the contacts folder of outlook
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="anoopism, post: 14176772, member: 119472"] [FONT=Times New Roman]Hi All[/FONT] [FONT=Times New Roman]I am VC++ developer and trying to Automate Microsoft Outlook using VC++ and got stucked at one point so need your help indeed.[/FONT] [FONT=Times New Roman]Expecting your reply for my question.[FONT=Times New Roman]:([/FONT][/FONT] [FONT=Times New Roman]what i want to achieve through VC++ code is :- [/FONT] [FONT=Times New Roman]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.[/FONT] [FONT=Times New Roman]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 [/FONT] [FONT=Times New Roman]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.[/FONT] [FONT=Times New Roman]so what i wanted to implement is to iterate all contact folders present in the outlook and get their path through[B] pFolder->GetFullFolderPath(); [/B]function and compare it with saved path if found then i can use that folder object for moving my contact exactly there[/FONT] [FONT=Times New Roman]something like this[/FONT] [FONT=Times New Roman]pItem->Save();[/FONT] [FONT=Times New Roman]pItem->Move([B]pFolder[/B]); [/FONT] [FONT=Times New Roman][B][COLOR=#000099]Partial Code snippet Below in VC++[/COLOR][/B][/FONT] [FONT=Times New Roman]_ApplicationPtr pApp;[/FONT] [FONT=Times New Roman]_ItemsPtr pItems;[/FONT] [FONT=Times New Roman]MAPIFolderPtr pFolder, pFolderChld;[/FONT] [FONT=Times New Roman]_ContactItemPtr pContact;[/FONT] [FONT=Times New Roman]HRESULT hr;[/FONT] [FONT=Times New Roman][COLOR=blue]try[/COLOR][/FONT] [FONT=Times New Roman]{[/FONT] [FONT=Times New Roman]hr=pApp.CreateInstance([COLOR=blue]__uuidof[/COLOR](Application));[/FONT] [FONT=Times New Roman][COLOR=blue]if[/COLOR] (FAILED(hr))[/FONT] [FONT=Times New Roman]{[/FONT] [FONT=Times New Roman]MsageBox([COLOR=#a31515]"Unable to instantiate Outlook."[/COLOR],[COLOR=#a31515]"Outlook Error"[/COLOR],MB_OK);[/FONT] [FONT=Times New Roman][COLOR=blue]return[/COLOR];[/FONT] [FONT=Times New Roman]}[/FONT] [COLOR=blue][FONT=Times New Roman]if[/FONT][/COLOR][FONT=Times New Roman](m_Option.GetCheck()) [COLOR=green]//default outlook contacts folder[/COLOR][/FONT] [FONT=Times New Roman]{[/FONT] [FONT=Times New Roman]pFolder=pApp->GetNamespace(_bstr_t([COLOR=#a31515]"MAPI"[/COLOR]))->GetDefaultFolder(olFolderContacts);[/FONT] [FONT=Times New Roman][COLOR=blue]if[/COLOR] (pFolder==NULL)[/FONT] [FONT=Times New Roman]{[/FONT] [FONT=Times New Roman]MessageBox([COLOR=#a31515]"Could not find default contacts folder."[/COLOR],[COLOR=#a31515]"Outlook Error"[/COLOR]);[/FONT] [FONT=Times New Roman][COLOR=blue]return[/COLOR];[/FONT] [FONT=Times New Roman]}[/FONT] [FONT=Times New Roman]}[/FONT] [FONT=Times New Roman][COLOR=blue]else[/COLOR] [COLOR=green]//display folder selection window[/COLOR][/FONT] [FONT=Times New Roman]{[/FONT] [FONT=Times New Roman][COLOR=blue]pFolder = pApp->GetNamespace(_bstr_t([/COLOR][COLOR=#a31515]"MAPI"[/COLOR][COLOR=blue]))->PickFolder();[/COLOR][/FONT] [COLOR=blue][FONT=Times New Roman]if (pFolder==NULL)[/FONT][/COLOR] [FONT=Times New Roman][COLOR=blue]return;[/COLOR][/FONT] [COLOR=blue][FONT=Times New Roman]if (pFolder->GetDefaultItemType()!=olContactItem)[/FONT][/COLOR] [FONT=Times New Roman][COLOR=blue]{[/COLOR][/FONT] [FONT=Times New Roman][COLOR=blue]MessageBox([/COLOR][/FONT][COLOR=#a31515][FONT=Times New Roman]"Select folder is not a Contact folder."[/FONT][/COLOR][COLOR=blue][FONT=Times New Roman],[/FONT][/COLOR][COLOR=#a31515][FONT=Times New Roman]"Outlook Contacts"[/FONT][/COLOR][COLOR=blue][FONT=Times New Roman]);[/FONT][/COLOR] [FONT=Times New Roman][COLOR=blue]return;[/COLOR][/FONT] [FONT=Times New Roman][COLOR=blue]}[/COLOR][/FONT] [FONT=Times New Roman][COLOR=blue]else[/COLOR][/FONT] [FONT=Times New Roman][COLOR=blue]{[/COLOR][/FONT] [FONT=Times New Roman][COLOR=blue]BSTR bsPath = pFolder->GetFullFolderPath();[/COLOR][/FONT] [FONT=Times New Roman][COLOR=blue]}[/COLOR][/FONT] [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook
Iterating all the contacts folder of outlook
Top