Ask a Question

Save As Log.mht rename file name as a date. Then send out email.

romanmfs
Frequent Contributor

Save As Log.mht rename file name as a date. Then send out email.

Hi!

I am beginner and only work with keyword cases have very basic understanding about scripts.

 

THINGS I NEED TO DO:

 

1. Save report as today's_date.mht

2. Automatically send out an email after report document created.

 

THINGS WHAT I'VE DONE:

1. Created 2 scripts for "save as" and it works 

2. Created a script for email automation and it give an error.

 

THINGS WHERE I'M STUCK:

 

1. Here is my "save as script" and it works but can somebody please help me to be able to save it as 'todays date' everytime.

 

function Test()

{
// Saving file
// ...

Log.SaveResultsAs("V:\\TestComplete\\Reports\\Report.mht", lsMHT);
}

 

2. Here is my script for email automation (outgoing server is correct etc), but I get an error: screenshot

I'm trying to use our Outlook mail which is installed locally.

 

function Test()
{
if (SendMail("rmarchuk@venturetechsolutions.com", "relay.ventureresource.local", "Roman Marchuk", "romanmfs@yahoo.com",
"Notification", "Hello QA, Your website is beautiful.", "V:\\TestComplete\\Reports\\Report.mht"))
Log.Message("Mail was sent");
else
Log.Warning("Mail was not sent");

}

 

 

Can somebody please help me I've been going back and forward with this for like 2 weeks now 😞

 

 

 

12 REPLIES 12
Marsha_R
Community Hero

To get the date, use the Today method

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/today.html

 

You can then build a string including that for the log output path.

 

 

Are you able to send email manually from the test box?  Try that first to see if the test Outlook can actually communicate with the mail server.

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
romanmfs
Frequent Contributor

Thanks for the reply, I will work on "todays date method" I tried to send out an email manually but could not even find that option, does that mean I am missing some applications that need to be installed in order to get it to work?

Thank You!

By manually, I meant send an email outside of TestComplete.  That's one way of making sure that your test box has the correct permissions/network setup/etc.  to actually talk to the mail server.  


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
romanmfs
Frequent Contributor

Oh yes that working for sure. Im  able to send and receivr emails from Outlook no problem

Did you follow the example for Outlook mentioned at the bottom of this page?

 

https://support.smartbear.com/testcomplete/docs/scripting/sending-email-from-scripts.html


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
romanmfs
Frequent Contributor

Just looked at it, the method I tried to use is the "send mail function" on the top of the same link. The example sample in a bottom gave me an error: "Unable to initialize MS Outlook"

Hm.  This thread seems to describe a similar problem.  Take a look and see if this helps:

 

https://community.smartbear.com/t5/TestComplete-General-Discussions/Sending-emails-with-outlook/td-p...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
romanmfs
Frequent Contributor

I got it to work! It was firewall related issue,

thanks!

romanmfs
Frequent Contributor

Now as far as "saving as" the name of the report+ date in the name (For example Report08142017, something like that) I tried messing with the script but get errors I dont think I set it up right, can you see check what I did wrong please.

 

Here is how how I was trying to set it up:

function Test()


{
// Saving file
// ...
Log.SaveResultsAs("V:\\TestComplete\\Reports\\Report" + aqDateTime.Today(), lsMHT);
}

{
Log.Message("Report Sent" + aqDateTime.Today());
}

 

 

Another question, is there a way to set up test complete to save reports in mht format as standard that way maybe I wont even need this script but just have "email script" sending out email with that report automatically.

 

 

Thanks again!

 

cancel
Showing results for 
Search instead for 
Did you mean: