Download and share automation modules and examples.
-
Support Team
- Site Admin

- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
-
Contact:
Post
by Support Team » Thu Jun 30, 2011 12:42 pm
Use this module at any position within your test suite to get informed about test runs by email. This is especially useful for overnight test executions on runtime machines.
Usage:
- Download the "SendMail.cs" file to your computer and import it into your project by right-clicking your project in Ranorex Studio and choose "Add" -> "Existing Item..."
- Drag & Drop the module to your test case and define the variables by binding them to a parameter in your test case
Variables:
To (required)
The email address of the message recipient.
From (required)
The email address of the message sender.
ServerHostname (required)
The hostname of the mail server.
ServerPort
The port of the mail server. Default is 25.
Subject
The subject of the message.
Message
The description of the message.
You do not have the required permissions to view the files attached to this post.
-
omayer
- Posts: 458
- Joined: Thu Oct 28, 2010 6:14 pm
Post
by omayer » Fri Aug 26, 2011 1:59 pm
How to send .rxlog file as attachement.
Thanks,
Beginner
Tipu
-
omayer
- Posts: 458
- Joined: Thu Oct 28, 2010 6:14 pm
Post
by omayer » Mon Aug 29, 2011 1:31 pm
Thank you Peter, It's worked
Beginner
-
Support Team
- Site Admin

- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
-
Contact:
Post
by Support Team » Thu Dec 22, 2011 11:44 am
If your server requires basic authentication (instead of using the standard Windows authentication), i.e. a user name and password, just edit following part in the the
SendMail method of the module:
SmtpClient smtp = new SmtpClient(ServerHostname, int.Parse(ServerPort));
smtp.Credentials = new System.Net.NetworkCredential("userName", "password");
smtp.Send(mail);
Regards,
Alex
Ranorex Team
-
omayer
- Posts: 458
- Joined: Thu Oct 28, 2010 6:14 pm
Post
by omayer » Wed May 15, 2013 5:41 pm
How to attach latest report w/out hard coded the attachment file, thank you in advance
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("TestSuite_20130515_114627.html");
mail.Attachments.Add(attachment);
Tipu
-
odklizec
- Ranorex Guru

- Posts: 7469
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Thu May 16, 2013 8:30 am
Hi, try this...
using Ranorex.Core.Reporting;
string RepName = TestReport.ReportEnvironment.ReportName;
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(RepName + ".html");
mail.Attachments.Add(attachment);
Last edited by
odklizec on Fri May 17, 2013 8:22 am, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at
Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
Support Team
- Site Admin

- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
-
Contact:
Post
by Support Team » Thu May 16, 2013 3:52 pm
Hello,
You might need to attach the data file since it is used to store information.
You could achieve to include a compressed report file (rxzlog) in your mail by using the following code snippet:
// get the zipped report file path
String zipFileName = Ranorex.Core.Reporting.TestReport.ReportEnvironment.ReportZipFilePath;
// adds the zipped report to the mail
if (System.IO.File.Exists(zipFileName))
{
System.Net.Mail.Attachment MyReport = new System.Net.Mail.Attachment(zipFileName);
mail.Attachments.Add (MyReport);
}
Please don't forget to enable 'Compressed Copy' of your report in the Test Suite settings.
Regards,
Markus (T)
-
omayer
- Posts: 458
- Joined: Thu Oct 28, 2010 6:14 pm
Post
by omayer » Thu May 16, 2013 6:09 pm
Thank you Markus, Not getting any attachment only mail body shows 'TestResult'
Code: Select all
// get the zipped report file path
MailMessage mail = new MailMessage(From, To, Subject, Message);
String zipFileName = Ranorex.Core.Reporting.TestReport.ReportEnvironment.ReportZipFilePath;
// adds th[attachment=0]ReportSetting.png[/attachment]e zipped report to the mail
if (System.IO.File.Exists(zipFileName))
{
System.Net.Mail.Attachment MyReport = new System.Net.Mail.Attachment(zipFileName);
mail.Attachments.Add (MyReport);
}
SmtpClient smtp = new SmtpClient(ServerHostName, int.Parse(ServerPort));
smtp.Send(mail);
Report.Success("Email has been sent to '" + To + "'.");
}
You do not have the required permissions to view the files attached to this post.
Tipu
-
odklizec
- Ranorex Guru

- Posts: 7469
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Fri May 17, 2013 8:13 am
Did you debug your send mail code? Does the rxzlog file exists at a time you call the send mail code? The thing is, that the "rxzlog" file is created after everything else is done. So make sure your send mail code is placed as the very last step in your test. The best place is probably Program.cs, just before
return error; line. Hope this helps?

Pavel Kudrys
Ranorex explorer at
Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
Andrew.J.Ebert
- Posts: 3
- Joined: Tue Jun 18, 2013 3:02 pm
Post
by Andrew.J.Ebert » Tue Jun 18, 2013 3:07 pm
In the direction is says "define the variables by binding them to a parameter in your test case." What do you mean by this? I am fairly unfamiliar with Ranorex and C# so I am completely lost trying to add this automatic report email. Any help or more detailed instructions greatly appreciated!
-
Support Team
- Site Admin

- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
-
Contact:
Post
by Support Team » Wed Jun 19, 2013 2:25 pm
Hello Andrew,
I would recommend to take a look at our User Guide.
The chapter
Data-Driven Testing describes how you could use variables and parameters.
Additionally, our
screencast provides a good overview.
We plan to implement an easier way to send reports via email in one of our next versions.
Regards,
Markus (T)
-
Andrew.J.Ebert
- Posts: 3
- Joined: Tue Jun 18, 2013 3:02 pm
Post
by Andrew.J.Ebert » Wed Aug 14, 2013 3:43 pm
I have the Sendmail.cs script located at the end of my test suite. However I keep getting an error that it cannot find the specified report file. I enabled the compressed copy of the report and am attaching the correct file.
I think this is because the report isn't generated until after Sendmail tries to execute. Is this correct? If so, were should it be placed in my test suite?
-
odklizec
- Ranorex Guru

- Posts: 7469
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Wed Aug 14, 2013 3:48 pm
Hi Andrew,
Yes, you need to call the SendMail as the very last step in your test suite (after creating the report file). I think the best place is
Program.cs, just before the final
return error; line.
See my post here:
http://www.ranorex.com/forum/send-mail- ... tml#p19797
Pavel Kudrys
Ranorex explorer at
Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
Andrew.J.Ebert
- Posts: 3
- Joined: Tue Jun 18, 2013 3:02 pm
Post
by Andrew.J.Ebert » Wed Aug 14, 2013 3:54 pm
Sorry I should read before I post.
I am pretty much C# illiterate so please bare with me on this. How would I call Sendmail.cs? Can you give me a code example by chance?