Office Compatible 97—Post to Exchange

by Ross Comer
Development Lead, Microsoft Office Compatible

June 1996

Abstract

This article provides a detailed description of the Post to Exchange feature of Office Compatible and the steps necessary to implement this feature into your custom application. It also provides sample code for both a C/C++ interface and an OLE Automation interface accessible from Visual Basic or VBA.

Description

Post To Exchange enables the user of a client application to post any document (not necessarily saved in an OLE storage) to Exchange so that co-workers can view and work with it. This call works the same as the Post to Exchange option in the Office applications. This API will work with any mail system which supports MAPI calls for posting documents.

Dialogs

When using the Post functionality with a system that uses Exchange, the following dialog will come up in the application and allow the user to select a folder in which to post the document.

C Interface

The following APIs should be used to post document to Exchange. 

FCanPostDoc returns False if Posting is not supported on this system.

   // Is Document Posting enabled?
   BOOL FCanPostDoc();  

The PostDoc call posts the document to Exchange.

   HRESULT PostDoc( 
      LPCWSTR wzFileName,   // full path of file to post 
                     // This parameter is used to post the document.
      LPWSTR wzSubject,   // Message subject
                     // This parameter launches the application.
      HWND hwnd);      // hWnd of the application window

Sample C Code

// Get the OfficeCompatible interface
IOfficeCompatible *pOC = CreateOfficeCompatible(L”SampleApp”, L”SampleAplication”)

if (pOC == NULL)
   return;

if (pOC->FCanPostDoc() == TRUE)
   pOC->PostDoc(wzFileName, wzFileName, hwndMain);

Automation Interface

Document Posting is also available through the Office Compatible Automation interfaces.

From the OfficeCompatible Object:
   Properties
      CanPostDocument - Boolean, read only
   Methods
      PostDocument([in,opt] fileName, [in,opt] Subject)

Sample VB Code

   Set OC = CreateObject("OfficeCompatible.Application")
   If OC Is Nothing Then Exit Sub
    
   On Error Resume Next
   OC.Init "OCBSamp", "Office Compatible Basic Sample App"

   If (Err.Number <> 0) Then
      Set OC = Nothing
      On Error GoTo 0
      Exit Sub
   End If
        
   If (oc.CanPostDocument = TRUE) Then
      OC.PostDocument(FileName)
   End If