#import "c:\Program Files\Common Files\Microsoft Shared\CDO\cdoex.dll" no_namespace raw_interfaces_only rename("Folder","EXFolder")
#import "c:\Program Files\Exchsrvr\BIN\cdoexm.dll" no_namespace raw_interfaces_only
#import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace raw_interfaces_only rename("EOF","adoEOF")
int main(void)
{
::CoInitialize(NULL);
{
IMailboxStoreDBPtr pMailboxStoreDB(__uuidof(MailboxStoreDB));
IDataSource2* pDataSource2 = NULL;
Fields* pFields = NULL;
HRESULT hr = pMailboxStoreDB->get_DataSource(&pDataSource2);
if (SUCCEEDED(hr))
{
//TODO Change this to reflect your environment
hr = pDataSource2->Open(
L"LDAP://MyServer.Mydomain.com/CN=2nd Mailbox Store,CN=First Storage Group,CN=InformationStore,CN=MyServer,CN=Servers,CN=SITE1,CN=Administrative Groups,CN=MyOrganization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=MyDomain,DC=com",
NULL,
adModeReadWrite,
adFailIfNotExists,
adOpenSource,
L"",
L"");
if (SUCCEEDED(hr))
{
//pVarFields = pMailboxStoreDB->GetFields();
hr = pMailboxStoreDB->get_Fields(&pFields);
if (pFields)
{
//Append property
_bstr_t _bstrName("msExchMessageJournalRecipient");
//TODO Change this to reflect your environment
_variant_t vFieldValue("CN=MyUser,CN=Users,DC=MyDomain,DC=com");
//Append only if the field is empty
hr = pFields->Append(
_bstrName,
adBSTR,
_bstrName.length(),
adFldUpdatable,
vFieldValue);
if (SUCCEEDED(hr))
{
//Update cache and directory
hr = pFields->Update();
hr = pDataSource2->Save();
}
pFields->Release();
}
}
pDataSource2->Release();
pDataSource2 = NULL;
}
}
::CoUninitialize();
return 0;
}