Forum Discussion

JBSoccerbrit's avatar
JBSoccerbrit
Contributor
9 years ago

Script Extensions Test Complete 11 - Email Logs from Keyword Test Run.

I've glossed over the documents in Test Complete 11 and see where it mentions creating Script Extensions to be used in Keyword Tests to send email for Keyword Test log results. I've never actually written one myself and was wondering if there is already a pre-existing plugin/app that exists or if anyone has any examples?

Thanks,

Here I can see how to send an email via gmail but no idea how to add the log as an attachment.
http://support.smartbear.com/viewarticle/9020/ 

3 Replies

    • JBSoccerbrit's avatar
      JBSoccerbrit
      Contributor

      Hi Tanya unfortunately neither of the links you provided really answer my question, or not to the point of where I understand how they answer my question specifically.

      I'm looking for more of a guide.

      Example;
      1) select call object method
      2) pick slpacker
      - What selections should be made here to grab the log files and put them in the correct extension type?
      3) select run code snippet
      - I'm assuming here I attempt to use one of the 3 methods available to send the email (SendMail which is built in, CDO or outlook).

      Thanks,

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Hi JBSoccerbrit,

         

        The community discussions I mentioned are talking about the ways on how to add attachments to email messages. sdruker uses the following code for this:

        Public Function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
         
          Dim i, schema, mConfig, mMessage, mAttach
          Err.Clear
          On Error Resume Next
          schema = "http://schemas.microsoft.com/cdo/configuration/"
          Set mConfig = Sys.OleObject("CDO.Configuration")
          mConfig.Fields.Item(schema + "sendusing") = 2 ' cdoSendUsingPort
          mConfig.Fields.Item(schema + "smtpserver") = "SMTP server" ' 
          'mConfig.Fields.Item(schema + "smtpserver") = "ServerName" ' SMTP server
          mConfig.Fields.Item(schema + "smtpserverport") = 25 ' Port number
          mConfig.Fields.Item(schema + "smtpauthenticate") = 1 ' Authentication mechanism
          ' mConfig.Fields.Item(schema + "sendusername") = "" ' User name (if needed)
          ' mConfig.Fields.Item(schema + "sendpassword") = "" ' User password (if needed)
          mConfig.Fields.Update
         
          Set mMessage = Sys.OleObject("CDO.Message")
          mMessage.Configuration = mConfig
          mMessage.MimeFormatted=true
          mMessage.From = mFrom
          mMessage.To = mTo
          mMessage.Subject = mSubject
        
          mMessage.HTMLBody = mBody
        
         aqString.ListSeparator = ","
        
          For i = 0 To aqString.GetListLength(mAttachment) - 1 
            mMessage.AddAttachment aqString.GetListItem(mAttachment, i)
           mMessage.Attachments.Item(1).ContentMediaType="application/octet-stream"
          Next
         
          mMessage.Send()
         
          If Err.Number > 0 Then
            Log.Error "E-mail cannot be sent", Err.Description
            SendEMail = False
          Else
            Log.Message "Message to <" + mTo + "> was successfully sent"
            SendEMail = True
         End If
         
        End Function

         

        If you want to attach the current test log, you will need to save it first. For this, you can use the Log.SaveResultsAs method. Please refer to the "SaveResultsAs method" article ( http://support.smartbear.com/viewarticle/75301/ ) for more information.

         

        Does it clarify the situation?