The following example uses the modSendMail function to send e-mail to a designated e-mail address using Simple Mail Transfer Protocol (SMTP). SMTP is a member of the TCP/IP suite of protocols that governs the exchange of electronic mail between message transfer agents. To use this example, you must have SMTP running.
For example, you can add the modSendMail function to an action to notify a user when an issue is opened or closed.
To use this example, add the function call to the script procedure on the Shared Script tab in the Workflow Process pane. Then, add the following example code to the beginning or end of the text in the Shared Script tab.
Calling the Function
'// modSendMail
'//
'// -----------------------------------------------------------------------------------
ret= modSendMail("sendto@Microsoft.com", " sendfrom@Microsoft.com ", "test subject", "test message")
call logger.printstring("send mail return value: " & ret & chr(13) & chr(10))
'// -----------------------------------------------------------------------------------
Example Script
'// ------------------------------------------------------------------------------------
'// Name : modSendMail
'// Purpose : send e-mail using SMTP
'//
'// Prereq : assumes that you have a smarthost assigned in the SMTP Settings to route
'// : mail using Exchange
'// Inputs : strTo - where to send e-mail
'// : strFrom - name to use for sending e-mail
'// : strSubject - subject of e-mail
'// : strBody - body of e-mail
'//
'// Return : True if function succeeds, otherwise false
'// ------------------------------------------------------------------------------------
Function modSendMail(strTo, strFrom, strSubject, strBody)
'// declarations
Dim objmail
'// assume failure
modSendMail = False
On Error Resume Next
Set mail = CreateObject("CDONTS.NewMail")
Call mail.Send(strFrom, strTo, strSubject, strBody)
'// check for fail
If Err Then
logger.printstring ("Unable to Send Mail" & vbCrLf)
Exit Function
End If
modSendMail = True
End Function