Microsoft KB Archive/322893

= How to enable message journaling for an Exchange Server mailbox store by using Visual C++ 6.0 =

Article ID: 322893

Article Last Modified on 10/25/2007

-

APPLIES TO


 * Microsoft Collaboration Data Objects for Exchange Management 1.1
 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft Exchange Server 2003 Enterprise Edition
 * Microsoft Exchange Server 2003 Standard Edition
 * Microsoft Visual C++ 6.0 Standard Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition

-



This article was previously published under Q322893



INTRODUCTION
This article describes how to enable message journaling on a Microsoft Exchange Server mailbox store by using the IMailboxStoreDB interface in Collaboration Data Objects for Exchange Management (CDOEXM).

When a mailbox store is enabled for journaling, the msExchMessageJournalRecipient attribute is set to the distinguished name of the user account object where you want to archive the messages for this store.



MORE INFORMATION
The following C++ sample demonstrates how to enable message journaling on a mailbox store:  Start Microsoft Visual C++ 6.0. On the File menu, click New. Click Win32 Console Application, type Q322893 in the Project name box, and then click OK. Click A simple application, and then click OK.  Replace all the code in the Q322893.cpp file with the following code:
 * 1) import &quot;c:\Program Files\Common Files\Microsoft Shared\CDO\cdoex.dll&quot; no_namespace raw_interfaces_only rename(&quot;Folder&quot;,&quot;EXFolder&quot;)
 * 2) import &quot;c:\Program Files\Exchsrvr\BIN\cdoexm.dll&quot; no_namespace raw_interfaces_only
 * 3) import &quot;c:\Program Files\Common Files\System\ado\msado15.dll&quot; no_namespace raw_interfaces_only rename(&quot;EOF&quot;,&quot;adoEOF&quot;)

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&quot;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&quot;,            NULL,             adModeReadWrite,             adFailIfNotExists,            adOpenSource,             L&quot;&quot;,            L&quot;&quot;); if (SUCCEEDED(hr)) {           //pVarFields = pMailboxStoreDB->GetFields; hr = pMailboxStoreDB->get_Fields(&pFields);

if (pFields) {               //Append property _bstr_t _bstrName(&quot;msExchMessageJournalRecipient&quot;); //TODO Change this to reflect your environment _variant_t vFieldValue(&quot;CN=MyUser,CN=Users,DC=MyDomain,DC=com&quot;);

//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; }  Search for TODO in the code, and then modify the code for your environment. Build and run the program.</li></ol>

<div class="references_section">