Share via


Creating and Sending an E-mail

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