OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
677 stars 95 forks source link

Emails Scheduled with 'Office.context.mailbox.item.delayDeliveryTime' Not Sending at Specified Time. #4847

Open CV-Ankit opened 1 month ago

CV-Ankit commented 1 month ago

I am experiencing an issue where emails scheduled using the Office.context.mailbox.item.delayDeliveryTime method are not being sent at the specified time, even though the email's delayDeliveryTime property is correctly set. Below is the function I used to schedule the email time.

//Set Email Delivery Time const setDeliveryTime = () => { const currentTime = new Date().getTime(); const milliseconds = 3 * 60000; const timeDelay = new Date(currentTime + milliseconds);

return new Promise((resolve, reject) => {
  Office.context.mailbox.item.delayDeliveryTime.setAsync(timeDelay, (asyncResult) => {
    if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
      resolve(asyncResult.value);
      console.log("Delay delivery time set successfully on " + timeDelay);
    } else {
      console.error("Failed to set Delivery Time:", asyncResult.error);
      reject(asyncResult.error.message);
    }
  });
});

};

Based on the code above, I can see the output in the Drafts folder, as shown in the screenshot below. image

CV-Ankit commented 1 month ago

Hello @samantharamon, Please check this issue if you can help. Your input would be greatly appreciated!

samantharamon commented 1 month ago

Hi @CV-Ankit,

Thanks for reporting this. From your screenshot, I see that you're experiencing this issue in Outlook on the web. Are you also experiencing this on other platforms by any chance?

CV-Ankit commented 1 month ago

Hi @samantharamon, No, I haven't tried that; I only tested it locally. Based on my understanding, everything is working properly, but I am having trouble understanding this specific aspect

samantharamon commented 1 month ago

Thanks, @CV-Ankit. I tested the code you provided in Outlook on the web and I'm able to replicate the behavior you're seeing. The scheduled message does get sent out a couple of minutes after the specified delivery time and appears in the Drafts folder in the meantime. I suspect this behavior is due to the time on the Exchange server. However, I'll let @exextoc investigate and confirm this.

CV-Ankit commented 1 month ago

Okay thank you...

rkpathak commented 1 month ago

@CV-Ankit Please share the platform (Win32 classic, New Outlook on Windows, OWA, Mac) are you facing this issue. Also record a video of the repro and share.

CV-Ankit commented 1 month ago

@rkpathak, I am using the Outlook Web to run the add-in. Below are the steps I performed, as shown in the attached video:

1. We have already implemented code to schedule an email. When the "Schedule Mail" button is clicked, the function is triggered, and the email is scheduled. You can see the Subject and Body in the video.

2. I can see the scheduled email in the Drafts folder. However, the first time I open it, no message is displayed.

3. When I double-click the email, a popup opens and then closes. After that, I can see the message in the email, highlighted in red.

Please refer to the URL below to view the video. Click here to view the video.

kumarshrey-msft commented 1 month ago

Thanks @CV-Ankit, from what I understand the issue is not exactly with the delivery time regarding when the mail will be delivered, but rather the UX: when we open the mail in draft folder after the API has been invoked, we don't get the notification highlighting the delivery time, this happens only when we subsequently open the draft later on. Let me know if my understanding of the issue is correct?

CV-Ankit commented 1 month ago

Yes @kumarshrey-msft, we are not able to see the message in the email, but it is also not sent at that time and remains in the draft. We can only see the message once we expand the email.

kumarshrey-msft commented 1 month ago

Thanks @CV-Ankit,

Regarding the item remaining in draft on OWA, it is expected behavior. Unlike classic Outlook on Windows where an item doesn't appear in the Drafts folder when its delivery is scheduled using the Office.context.mailbox.item.delayDeliveryTime.setAsync call, in case of OWA, New Outlook on Windows and Outlook Mac, the scheduled item appears in the Drafts folder while waiting for the scheduled time and can also be edited while it's sitting in the Drafts folder. However, the item will be sent at the time set via the delayDeliveryTime.setAsync API.

CV-Ankit commented 1 month ago

Thanks @kumarshrey-msft , As you can see in my first message, I used setAsync to schedule the email, but it is not being sent. I just want the email to be sent at the scheduled time.

Swathy-Mothilal commented 1 month ago

@CV-Ankit we are still unable to reproduce the issue on our side. Upon reviewing the video, we noticed that when the email is being composed, the recipient field is empty. However, when the same email is displayed in the 'Drafts' folder, a recipient is visible. Could you clarify how the recipient field is being populated?

CV-Ankit commented 1 month ago

@Swathy-Mothilal, Thanks for the review. In the provided video, we have hidden content such as the email address, inbox emails, etc. Were you able to schedule an email using the method mentioned in my issue (#4847), and does it send the email at the scheduled time?

Swathy-Mothilal commented 1 month ago

@CV-Ankit Thanks for the info. We are able to repro the issue, and it has been put in our backlog. We unfortunately have no timelines to share at this point.

Internal tracking id: Office 4891936