Working with ReceivedMessage
Working with ReceivedMessage
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
In workflow, a ReceivedMessage is a reply posted to a folder as part of an existing workflow process. The reply is received in response to an e-mail initiated by the workflow process. These replies contain information necessary to advance the workflow. The ReceivedMessage Property returns the IWorkflowMessage Interface of a reply to an e-mail sent using the SendWorkflowMessage Method. The ReceivedMessage Property is available only in an OnReceive event. This is known as e-mail workflow and is used in a situation where users do not have a direct connection to the corporate network and the Exchange store. For more information about e-mail workflow, see Web-Based and E-Mail Workflow.
In e-mail workflow, you use the IWorkflowMessage Interface with the SendWorkflowMessage Method to send e-mail whose reply can be matched with an existing workflow process. Use the GetNewWorkflowMessage Method to get an IWorkflowMessage Interface. The SendWorkflowMessage Method adds the following two fields to the message:
- https://schemas.microsoft.com/cdo/workflow/workflowmessageid
- https://schemas.microsoft.com/cdo/workflow/parentprocinstance
These two fields and values are required properties in the reply form so that the workflow engine can correlate the reply to the original workflow process and item. When the workflow engine matches a reply, the ReceivedMessage property contains the IWorkflowMessage Interface in the reply. You can access and modify the Fields collection of the reply to advance the workflow.
In the following code, SendWorkflowMessage creates and populates the workflowmessageid and parentprocinstance fields on the message that it sends. When a client, such as Microsoft® Outlook®, receives the message, a macro embedded in MyForm copies the values from the fields on the message to fields of the same name on the reply. When the workflow engine handles the reply from the client form, it correlates the reply to the original item based on the workflowmessageid and parentprocinstance fields. An OnReceive event triggers the UpdateWorkflowItem procedure, which consolidates the message body into a TrackingTable field.
To track responses, such as voting, do the following:
- Ensure that your form contains the field https://schemas.microsoft.com/cdo/workflow/response.
- Bind the form control containing the response data to the https://schemas.microsoft.com/cdo/workflow/response field on the form.
The workflow engine writes the value of the https://schemas.microsoft.com/cdo/workflow/response field to the response field of the TrackingTable. Response tracking is automatic and requires no coding on your part.
The code in the following example assumes that you have created and published a form in Outlook called MyForm with the workflowmessageid and parentprocinstance properties.
VBScript
' In Form script for MyForm: Sub Item_Reply(ByVal Response) set CurrentProp = Response.UserProperties.Add( "https://schemas.microsoft.com/cdo/workflow/parentprocinstance", 1) CurrentProp.Value = Item.UserProperties("https://schemas.microsoft.com/cdo/workflow/parentprocinstance").Value set CurrentProp = Response.UserProperties.Add ("https://schemas.microsoft.com/cdo/workflow/workflowmessageid", 1) CurrentProp.Value = Item.UserProperties("https://schemas.microsoft.com/cdo/workflow/workflowmessageid").Value End Sub ' EventType: OnChange (original workflow item) ' Action Script Procedure: SendWorkflowItem 2 '"cdowfStrict" ' EventType: OnReceive (reply to sendworkflowitem) ' Action Script Procedure: UpdateWorkflowItem ' In Shared Script: Sub SendWorkflowItem(cdowfMethod) Set WFMsg = WorkflowSession.GetNewWorkflowMessage with WFMsg .To = WorkflowSession.Sender .Subject = "Workflow Item" .TextBody = "Workflow Item body" .Fields("https://schemas.microsoft.com/mapi/proptag/0x001A001E").Value = "IPM.Note.MyForm" .Fields.Update .SendWorkflowMessage cdowfMethod end with End Sub Sub UpdateWorkflowItem() with WorkflowSession .TrackingTable.Fields("custom0") = .TrackingTable.Fields("custom0") & vbCrLf & _ .ReceivedMessage.TextBody .TrackingTable.Fields.Update end with End Sub
Related Topics
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.