Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to send an email via Silk Test Workbench .net script

How to send an email via Silk Test Workbench .net script

Silk Test has no in-built functionality to send email in a test.  However you can manually script this using the Simple Mail Transfer Protocol (SMTP).

Please see example below that creates the mail message and sends the email to a recipient using a Silk Test Workbench .net script:-

Public Module Main
    Dim _desktop As Desktop = Agent.Desktop
   
Public Sub Main()
    'create the mail message
    Dim mail As New System.Net.Mail.MailMessage()

    'set the addresses
    mail.From = New System.Net.Mail.MailAddress("EmailFrom@test.com")
    mail.To.Add("EmailTo@test.com")

    'set the content
    mail.Subject = "This is a Test Email from SilkTest"
    mail.Body = "This is the body content of the email."

    'set the server
    Dim smtp As New System.Net.Mail.SmtpClient
    smtp.Host = "smtp.live.com"
    smtp.Port = 587
    smtp.EnableSsl = True
    smtp.Credentials = New System.Net.NetworkCredential("EmailFrom@test.com", "Password")
   
    'send the message
    Try
        smtp.Send(mail)
        Workbench.ResultComment("Your Email has been sent successfully - Thank You")
    Catch exc As Exception
           Workbench.ResultComment("Send failure: " & exc.ToString())
    End Try

    End Sub

End Module

 

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-10-10 14:39
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.