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



The information in this article applies to:

  • Microsoft Collaboration Data Objects for Exchange Management (CDOEXM)
  • Microsoft Exchange 2000 Server
  • Microsoft Exchange Server 2003 Enterprise Edition
  • Microsoft Exchange Server 2003 Standard Edition
  • Microsoft Visual C++ Standard Edition, version 6.0
  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft Visual C++, 32-bit Professional Edition 6.0

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:
  1. Start Microsoft Visual C++ 6.0.
  2. On the File menu, click New.
  3. Click Win32 Console Application, type Q322893 in the Project name box, and then click OK.
  4. Click A simple application, and then click OK.
  5. Replace all the code in the Q322893.cpp file with the following code:
    #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;
    }
    
  6. Search for TODO in the code, and then modify the code for your environment.
  7. Build and run the program.

REFERENCES

For more information about how to use the Exchange System Manager to enable journaling, click the following article number to view the article in the Microsoft Knowledge Base:

261173 How to enable message journaling in Exchange 2000

For additional information about message journaling, see the Exchange System Manager Help file.

For additional information about CDOEXM, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:5/24/2005
Keywords:kbProgramming kbHOWTOmaster kbhowto KB322893