EmailModule & body text

Ask general questions here.
SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

EmailModule & body text

Post by SanMan » Fri Apr 06, 2018 5:45 am

Hi,

I am using EmaiModule in [TEARDOWN]

How should I call it to add data after testrun?

I would like to add testrun date to subject and some details about failed cases to body.

Could someone please give some example code how to do it.

SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Re: EmailModule & body text

Post by SanMan » Fri Apr 06, 2018 7:19 am

Should I add the code here:

Code: Select all

private void OnTestSuiteCompletedSendResult(object sender, EventArgs e)
        {
            var currentTestSuiteStatus = TestReport.CurrentTestSuiteActivity;
            var reportFile = CreateReports();

            this.Subject = "Something here?";
            
            if (this.SendEmailOnFailure && currentTestSuiteStatus.Status == ActivityStatus.Failed
                || this.SendEmailOnSuccess && currentTestSuiteStatus.Status == ActivityStatus.Success
                || this.SendZippedReportOnComplete && !this.SendEmailOnFailure && !this.SendEmailOnSuccess
                || this.SendPdfReportOnComplete && !this.SendEmailOnFailure && !this.SendEmailOnSuccess)
            {
                EmailLibrary.SendEmail(
                    this.Subject,
                    this.To,
                    this.From,
                    this.Body,
                    reportFile,
                    this.ServerHostname,
                    int.Parse(this.ServerPort),
                    this.UseSSL,
                    this.Username,
                    this.Password);
            }
        }

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: EmailModule & body text

Post by Support Team » Fri Apr 06, 2018 4:12 pm

Hi SanMan,

You can add custom body text here - just ensure it remains a string.
emailbody.png
Note, += will append to the end of the body, while = will replace the body text.

I hope this helps!

Cheers,
Ned
You do not have the required permissions to view the files attached to this post.

SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Re: EmailModule & body text

Post by SanMan » Mon Apr 09, 2018 6:25 am

Hi Ned,

thank you for your help. Just what I wanted to know.

One more question about EmailModule:

- Can I attach report as *.html so it can be opened without Ranorex Report Viewer?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: EmailModule & body text

Post by odklizec » Mon Apr 09, 2018 7:19 am

SanMan wrote:- Can I attach report as *.html so it can be opened without Ranorex Report Viewer?
Only if you attach it zipped along with *.rxlog.data. *.xsl, *.css, *.png and report image folder. Report file is not just HTML that must be included. Additionally, you must rename *.rxlog.data to *.html.data.
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

SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Re: EmailModule & body text

Post by SanMan » Mon Apr 09, 2018 10:39 am

Thank you!

I also found, that when I add text to body, Environment.newline does not work (work, but email is send as *.html) and outlook does not show the line break.

I tried to use "</br>" instead but it did not help.

Am I able to set somewhere that email is sent as text?