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

SAP iRPA - How to use Outlook replyAll()


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

  // Resets the working mails list.
  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.");
  //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.