Forum Discussion

bhavyaNaveen's avatar
5 years ago

How to send report in TestComplete via email

How to send report in TestComplete via email with complete log details

  • use the buildtin sendmail function alongside the log.saveresultas method in order to generate the complete log details, and attach it with the email you want to send. 

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

    https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/saveresultsas.html

    modify the script below and include it as your final test item at the project level.

    def test():
      Log.SaveResultsAs(Project.ConfigPath + "\\MHT_Files\\" + ProjectSuite.TestItems.Current.ProjectName + ".mht", lsMHT)
      SendMail("justin.kim@smartbear.com", "mail.smartbear.com", "Justin Kim", "justin.kim@smartbear.com", "Error in Test Run", "Please take a look at the attached results file", Project.ConfigPath + "\\MHT_Files\\" + ProjectSuite.TestItems.Current.ProjectName + ".mht")
      

     

  • anupamchampati's avatar
    anupamchampati
    Frequent Contributor

    if you have report in any other formal live Excel or Text file in any location you can attach that as well.


    function SendEmail()
    {
    var Filename1 = "{Path}\test1.xlsx";
    var Filename2 = "{Path}\test2.xlsx";
    var Filename3 = "{Path}\test3.txt";
    var Filename4 = "{Path}\test4.xlsx";
    var MessageBody = "Test";

    SendMail("Receiver Email ID","mailrelay of company server","Sender Name","Sender email id","Subject",MessageBody,Filename1,Filename2,Filename3,Filename4);
    }