Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q322893

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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:

↑ Back to the top


Keywords: KB322893, kbhowto, kbhowtomaster, kbprogramming

↑ Back to the top

Article Info
Article ID : 322893
Revision : 6
Created on : 10/25/2007
Published on : 10/25/2007
Exists online : False
Views : 385