Share this page

# Sending Mail when a Defect is Submitted

This example sends mail when a defect is submitted.

Add a call to the `SendDefect` procedure in the `Bug_AfterPost` event procedure.

Note: If the `SendDefect` procedure is called before the defect is submitted, the values that were changed in the current modification will not be included. The database is updated with the new values only after the defect is posted.

    Sub SendDefect (iObjectId, strTo, strCc, strSubject, strComment)
            On Error Resume Next
            Dim objBugFactory, objBug
            Set objBugFactory = TDConnection.BugFactory
            Set objBug = objBugFactory.Item(iObjectId)
            objBug.Mail strTo, strCc, 2, strSubject, strComment
            Set objBug = Nothing
            Set objBugFactory = Nothing
            PrintError "SendDefect"
            On Error GoTo 0
    End Sub

The constant `2` in the call to `objBug.Mail` indicates that the history should be included with the mail. For a list of the constants that can be used to customize email, refer to the `tagTDMAIL_FLAGS` enumeration in the ALM Open Test Architecture API Reference. In workflow scripts, use numeric constants and not the enumeration values.

https://admhelp.microfocus.com ALM 8942
Tips to improve your search results... ALM Help Center ALM Help Center ALM Help 15.5-15.5.1 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: