Ask a Question

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

rajabe9209
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, "smtp.gmail.com", From_Mail , "", Subject, Body_mail, Attachment);

1 REPLY 1
SaravanaKumar_N
Contributor

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

More details here -

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

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;

  try
  {
    schema = "http://schemas.microsoft.com/cdo/configuration/";

    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)

    mConfig.Fields.Update();

    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;
    mMessage.Send();

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

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

}

 

cancel
Showing results for 
Search instead for 
Did you mean: