Forum Discussion

r12_aparna's avatar
r12_aparna
Occasional Contributor
13 years ago

Not able to send mail from test complete 8.0

I have the below code where I have to send a mail to my manager. However, when i run the test, ti doens't send any. Can somebody pelase help me.




sub FinalizeLogging


  ' display the test run start and end time and the duration


    dim endTime, startTime, duration


    dim totalSeconds, totalTime, hr, min, sec


 


    ' log finish time and total duration 


    startTime = GlobalData.get_LogStarted


    endTime = Now()


    Log.Message(">>>>> Testing started @ " & startTime & " <<<<<")     


    Log.Message(">>>>> Testing finished @ " & endTime & " <<<<<") 


  


    totalSeconds = DateDiff("s", startTime, endTime)


    totalTime = TimeSerial(0, 0, totalSeconds)


 


    hr = Hour(totalTime)


    min = Minute(totalTime)


    sec = Second(totalTime)


 


    duration = PEPUtilities.AppendZeroWhenLessThanTen(hr) & ":" & PEPUtilities.AppendZeroWhenLessThanTen(min) & ":" & PEPUtilities.AppendZeroWhenLessThanTen(sec)


 


    Log.Message(">>>>> Testing took = " & duration & " <<<<<")


 


  ' save the log file


    dim logFilePath


    logFilePath = PEPUtilities.AppendResultsSuffix(GlobalData.get_LogFilePath)


 


    ' save the log results to a network drive


    if (Log.SaveResultsAs(logFilePath, lsHTML) = true) then


      ' send automate email when complete        


      dim body


 


      ' log the automated testing complete results


      if (Log.ErrCount > 0) Then


        result = "The test run failed with error(s)"


      elseif (Log.WrnCount > 0) Then


        result = "The test run failed with warning(s)"


      else


        result = "The test run was successful"


      end if


 


      ' build the body of the email


      body =  "PEP Automated Testing Results" & vbCrLf &_


              "----------------------------------------" & vbCrLf &_


              vbCrLf &_


              " Testing Parameters: " & GenerateTestRunParameterSet & vbCrLf &_


              " Started: " & startTime & vbCrLf &_


              " Finished: " & endTime & vbCrLf &_


              " Duration: " & duration & vbCrLf &_


              " Result: " & result & vbCrLf &_


              vbCrLf &_


              " Results: " & logDirectory & "\index.htm"


 


      ' using the MAPI api send the email 


      if PEPConfiguration.SendingEmailIsEnabled then


        if (BuiltIn.SendMail(PEPConfiguration.ToEmailAddress, PEPConfiguration.SMTPHost, PEPConfiguration.FromName, PEPConfiguration.FromEmailAddress, PEPConfiguration.EmailSubject, body) = false) Then


          Log.Warning "The automated testing complete email could not be sent"


        end if  


      end if


    end if


end sub


 


Sub GeneralEvents_OnStopTest(Sender)


  Delay(5000)


  


  for i = 1 to Log.FolderCount 


    Log.PopLogFolder


  next


 


  ' finalize the logging of the test


  FinalizeLogging


End Sub             

1 Reply

  • I suggest to start from verifying values of parameters for SendMail - are they all right?

    Did this code worked before? If yes, try to understand what have beed changed that could break sending email. If you have access to the logs of mail server then they may help.