Share via


Creating and Sending an E-mail

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.

This example illustrates the use of the GetNewWorkflowMessage method. This is a member method of the WorkflowSession intrinsic object. You do not have to create the WorkflowSession object, because the workflow engine passes it to the script host. GetNewWorkflowMessage returns a WorkflowMessage object. As a result, the script can use the IWorkflowMessage interface to set the "From," "To," "Subject," and "TextBody" fields, as well as send the message.

Example Script

Sub SendMail(MySubject)
   Set WFMsg = WorkflowSession.GetNewWorkflowMessage()
   With WFMsg
      .From = WorkflowSession.Sender
      .To = WorkflowSession.Sender
      .Subject = MySubject
      .TextBody = WorkflowSession.StateFrom & " -> " & WorkflowSession.StateTo
      .SendWorkflowMessage 0 'cdowfNoTracking
   End With
End Sub

See Also

Scripting in the Workflow Designer for Exchange Server | Script Examples for Exchange Server | Creating Script Procedures