Hi Support,
I am trying to send mail after each execution but i am getting this as a error message.
The code which i am using is same as you have mentioned i.e.
"/*
* Created by Ranorex
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using System.Net.Mail;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
namespace Ranorex.Modules
{
/// <summary>
/// Use this module at any position of your test suite to get informed about test runs by email.
/// This is especially useful for overnight test executions on runtime machines.
/// </summary>
[TestModule("EEE7C8D8-D950-40EF-B24A-1A9A87C0DA21", ModuleType.UserCode, 1)]
public class SendMailModule : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public SendMailModule()
{
// Do not delete - a parameterless constructor is required!
}
#region Variables
string _to = "";
[TestVariable("D089186D-7919-4023-8165-B68F9151C6A7")]
public string To
{
get { return _to; }
set { _to = value; }
}
string _from = "";
[TestVariable("BDB3FC8C-1E51-448F-9049-AEF0B247DBDB")]
public string From
{
get { return _from; }
set { _from = value; }
}
string _subject = "Ranorex Module Report";
[TestVariable("398FF772-C15C-4b91-954B-34CC636DEDC9")]
public string Subject
{
get { return _subject; }
set { _subject = value; }
}
string _serverHostName = "smtp.gmail.com";
[TestVariable("0EE4CB1E-D738-4DE8-B122-92B3CCE6F70C")]
public string ServerHostname
{
get { return _serverHostName; }
set { _serverHostName = value; }
}
string _serverPort = "25";
[TestVariable("4C6A889D-BACE-4AE1-9EEF-40EA26775574")]
public string ServerPort
{
get { return _serverPort; }
set { _serverPort = value; }
}
string _message = "Test Report";
[TestVariable("D49672F4-3021-4460-96DA-2EC11AE318A8")]
public string Message
{
get { return _message; }
set { _message = value; }
}
#endregion
void ITestModule.Run()
{
SendMail();
}
void SendMail()
{
try
{
MailMessage mail = new MailMessage("
[email protected]", "
[email protected]", Subject, Message);
SmtpClient smtp = new SmtpClient(ServerHostname, int.Parse(ServerPort));
smtp.Credentials = new System.Net.NetworkCredential("sample username", "sample password");
smtp.Send(mail);
Report.Success("Email has been sent to '" + To + "'.");
}
catch(Exception ex)
{
Report.Failure("Mail Error: " + ex.ToString());
}
}
}
}
"
"Mail Error: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. o10sm19811782pdr.96 - gsmtp
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)".