Wednesday 11 August 2010

Email notification using CDO

The email notification in automation is used to send emails to the users after the tests are completed.
Using CDO :
This is the simple way to send an email notification
' Set the company specific information
' Company Internet Domain Name
ODomain = "xyz.co.uk"

' Set the SMTP server IP
oMyIP = "xxx.yyy.zzz.www"

' Where do you want the message to be delivered
oTo = Email_Address '"Toemail@your.com"

' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing", _
cdoSendUsingPort = 2, _
cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"

' Create the CDO connections.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

' SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort

' Set the SMTP server address here.
.Item(cdoSMTPServer) = oMyIP
.Update
End With

' Set the message properties.
With iMsg
Set .Configuration = iConf
.To = oTo
.Bcc = "you@your.com"
.Cc = cc@your.com
.From = from@xyz.com
.Subject = ScenarioName & "scenario Execution Status
.HTMLBody = "body of the email"
End With
iMsg.AddAttachment file_path_attachment
'Send the message.
iMsg.Send






No comments:

Post a Comment