Create a Outlook pst file with Visual C++?

C

cyrus_castleman

I want to create a Outlook pst file and add mail folders, messages,
contacts, etc. into the pst file in my Visual C++ program. The Outlook
is already installed on my computer. And I heard of that Outlook
Automation and MAPI can do the above tasks. However, as I'm not very
familiar with them. I wonder, if there is such samples that I can
follow as a quick start. Thank all of you very much.
 
S

Sue Mosher [MVP-Outlook]

There are few C++ samples and, I suspect, none for the Namespace.AddStore method that you'd need to use to create the .pst file. If you're new to Outlook automation, you might want to start with the object model resources listed at http://www.outlookcode.com/d/outtech.htm

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Joined
Dec 14, 2012
Messages
2
Reaction score
0
Hi All Expecting yours reply for my question.

what i want to achieve 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();
}

 

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