Forum Discussion

romanmfs's avatar
romanmfs
Frequent Contributor
7 years ago

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

    • romanmfs's avatar
      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!

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        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.  

  • liquidphantom's avatar
    liquidphantom
    Occasional Contributor

    I wrote this vb script for my log files "strPrefix" refers to a variable I have that prefixes a the file with Passed, error, timeout etc depending on a flag set in one of the general events.

     

    It will create a TestExecuteLogs folder in root c:\ and a date stamped folder in there, in those folders each log will have a datetime stamp in the file name.

     

     

    Sub SaveLog
        Dim CurDate, CurTime, strCurDate, strCurTime, strFolder, strFile, strPrefix, strLogPath
    
        strPrefix = Project.Variables.strLogPrefix
        
        strLogPath = ProjectSuite.Variables.strSuitePath
        
        'get current date and time 
        CurDate = aqDateTime.Today
        CurTime = aqDateTime.Time
        
        'convert current date and time       
        strCurDate = aqConvert.DateTimeToFormatStr(CurDate, "%Y%m%d")
        strCurTime = aqConvert.DateTimeToFormatStr(CurTime, "%H%M%S")
        
        strCurTime = Replace(strCurTime, ":","-")
        
        Log.SaveToDisk
        'Log save breakpoint
    
        'Save log out to mht package
        strFolder = "C:\TestExecuteLogs\" & strCurDate &"\" 
        strFile = strPrefix & "Log" & "_" & strCurDate & "_" & strCurTime & ".mht"
        
        If aqFileSystem.Exists(strFolder) = True Then
            Call Log.SaveResultsAs(strFolder & strFile, lsMHT)
        End If
        
        If aqFileSystem.CreateFolder(strFolder) = 0 Then
            Call Log.SaveResultsAs(strFolder & strFile, lsMHT)
        End If
    End Sub