Skip to Content
2
May 15, 2020 at 09:32 AM

SAP iRPA - How to use Outlook replyAll()

137 Views

Hello Expert,

Could anyone give an example about ctx.outlook.mail.replyAll? I try to use it. ฺBut it doesn’t work for reply. It's like create new email.

My workflow use for retrieve email and download attached files to my PC and use ctx.outlook.mail.replyAll for a reply to same my collection.

This is my scripts that use for work the process.

 // Outlook
function readMail(){

  // Outlook Init
  ctx.outlook.init();

  // Resets the working mails list.
  ctx.outlook.mail.resetMailCollection();
  
  //SearchByCriteria
  ctx.outlook.mail.searchByCriteria({
  subject : "Demo%",
  read : 0,
  maxRow : 20
  });

  var mails = ctx.outlook.mail.getFilteredTable(); //Get Filtered email

  //Loop mails for do Activities
  ctx.log("Mail length: " + mails.length,e.logIconType.Info);
  for(var i = 0; i < mails.length; i++){
    ctx.outlook.mail.retrieveMail({EntryID : mails[i]['EntryID'], StoreID : mails[i]['StoreID']});
  }
  //for Same mail index
  for (var i = 0; i<ctx.outlook.mail.getCollectionLength(); i++){
    for (var j=0;j<ctx.outlook.mail.getAttachmentsCount((i));j++){ 
      ctx.outlook.mail.attachmentSave(i, "C:\\temp\\" + ctx.outlook.mail.getAttachmentsName(i)[j],{Index : ++j} );
    }
    //Reply by same Collection
    ctx.outlook.mail.setBody(i,"Download File Successfuls.");
    ctx.outlook.mail.replyAll(i);
    ctx.outlook.mail.send(i);                                 
  }
  //Outlook End
  ctx.outlook.end();
}

From my script, it can download the attached files. However, the replyAll() step will send email with the same information that stores in my collections and change body to “Download File Successful.”. Sender is also same from my collection. It's not change my email address in outlook to sender. It’s not take the old body email to use for reply.

Please help me to solve this problem.

Thank you.

Best regards.