New Calendar strange behavior

F

Frederic Codron

Hi,

I'm creating an add-in with VC++ 6, no MFC or CDO allowed.
I need to create a new calendar folder, in order to put in it the
appoinments of other people. I'm using CreateFolder, and set
PR_CONTAINER_CLASS to IPF.appointment. So far, so good, the new folder is
created and has the good type.

However, when I want to add a new appointment in it directly with Outlook,
this appointment goes in the default calendar, and not in my new folder. Am
I missing some code ?

Thanks for help.
Regards,
Frédéric

Below is the code to create the folder :

lHr = pHrGetOneProp(mapi_msgstore, PR_IPM_SUBTREE_ENTRYID, &aIPM_Eid);
if (lHr == S_OK)
{ anEid = aIPM_Eid;
pMAPIFreeBuffer(aIPM_Eid);
}

// Got the EntryId ?
if (!anEid.isempty())
{ ULONG IMPRootType;
// The EntryId is good, we open the folder
lHr = mapi_msgstore->OpenEntry(anEid.size, anEid.ab, NULL, MAPI_MODIFY,
&IMPRootType, (IUnknown**)&aRootFolder);

if (lHr == S_OK)
{ // If the thing opened is not a folder, forget it
if (IMPRootType != MAPI_FOLDER)
{ aRootFolder->Release();
aRootFolder = NULL;
}
}
}

if (aRootFolder != NULL)
{ IMAPIFolder *aFolder;
// Create a new Calendar Folder
lHr = aRootFolder->CreateFolder(FOLDER_GENERIC,
pDeviceConfig->GetDeviceCaption().GetBuffer(0),
pDeviceConfig->GetDeviceId().GetBuffer(0),
NULL, 0, &aFolder);

if (lHr == S_OK)
{ aFolder->SaveChanges(FORCE_SAVE|KEEP_OPEN_READWRITE);
CMAPIFunctions::SetMAPIProp(aFolder, PR_CONTAINER_CLASS,
CString("IPF.appointment"));
aFolder->SaveChanges(FORCE_SAVE);

aFolder->Release();
aFolder = NULL;

bCreated = true;
}

aRootFolder->Release();
aRootFolder = NULL;
}
 

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