Ask a Question

How to use Sendmail attachment as Insert as Text to display Body as Summary Format

Occasional Contributor

How to use Sendmail attachment as Insert as Text to display Body as Summary Format

 Am using Send mail Method of Testcomplete in the Attachment i would like to use "Outlook--> Insert as Text" 

so that my HTML Summary report would get printed in the Body of the email


SendMail(emailRecipients, "", From_Mail , "", Subject, Body_mail, Attachment);


You might have to use CDO here. This is what we do... 

More details here -

function SendEmail()

  var mBody = "C:\\Report.html"; // Your HTML file location
  var schema, mConfig, mMessage;  

  var cdoSendUsingPort = 2;  
  var emailSMTPServer; 		 // Your office SMTP server details, will be able to get these from your System Admin.
  var smtpServerPortNumber = 25; // This should work, if not get the SMTP server port details as well
  var smtpAuthentication = 1;

    schema = "";

    mConfig = Sys.OleObject("CDO.Configuration");
    mConfig.Fields.Item(schema + "sendusing") = cdoSendUsingPort; 
    mConfig.Fields.Item(schema + "smtpserver") = emailSMTPServer; 
    mConfig.Fields.Item(schema + "smtpserverport") = smtpServerPortNumber; 
    mConfig.Fields.Item(schema + "smtpauthenticate") = smtpAuthentication; 

    // mConfig.Fields.Item(schema + "sendusername") = ""; // User name (if needed)
    // mConfig.Fields.Item(schema + "sendpassword") = ""; // User password (if needed)


    mMessage = Sys.OleObject("CDO.Message");
    mMessage.Configuration = mConfig;

    mMessage.From = <enter EmailSender details>;
    mMessage.To = <enter EmailRecipients details>;
    mMessage.Cc = <enter EmailCCRecipents details>;
    mMessage.Subject = <enter Email Subject details>;

    var str = aqFile.ReadWholeTextFile(mBody, aqFile.ctANSI);
    mMessage.HTMLBody = str;

    Log.Message("Message was  sent successfully.");
    return true;

  catch (exception)
    TestLog.Warning("E-mail cannot be sent", exception.description);
    return false;



Showing results for 
Search instead for 
Did you mean: