Microsoft 365 Email (Outlook) Search module not returning Output bundle

My scenario is set up to receive emails, check the body content for specific keywords, and reply (or not) depending on whether those keywords are present.

I have a Webhook (Mailhook) trigger which instantly triggers when it receives an email. The Primary email address (used for work) receives an email and forwards it to the Mailhook. This forwarding is set up through Microsoft 365 directly not Make.

When the Mailhook receives the mail, it passes through a filter which checks the sender’s email address - I only want to reply to one specific email address. This email is called “Referrals” on the screenshot.

I can read the body content from the mailhook module but I cannot receive the specific Outlook Message ID, which is required for the Reply modules later in the Scenario.

My Attempt to receive the Message ID is done through an Outlook (Microsoft 365 Email) Search Module. I previously searched using the Subject Line received in the Mailhook but this would sometimes return the wrong email. I now Search using the function “From:[referrals email] AND Sent:today”. The Sent Today check is an extra security step to ensure it doesn’t reply to an old email by mistake. In the Search Module I also Order By (sort) receivedDateTime desc to get the most recent email. I also limit return parameters to 1.

Note there is a warning Important: this parameter is not supported with Search. under the Order By section, but I’m not 100% sure what this effects as in all my testing it always returned the most recent email - maybe just luck.

My Issue:
An email came in this morning which, if the scenario ran as intended, would have been replied to. BUT the Search Module didn’t return an output.

I obviously don’t have the search module set up optimally but I’m unsure how to best set it up. Why or How would the Search Module not return an output when the Scenario will only run when there is a new email to output in the first place?

EDIT: I am wondering if the reply is happening TOO QUICK so that the email hasn’t fully loaded on the Outlook server? Is that a possibility? I say this as I just ran a test run and the search module successfully found the old email (the one from the failed run) as it should have in the first place?

The function of this email is to win work and emails require a reply within 1min to have a chance of successfully winning the job.

Let me know if you need anymore clarification - thanks to anyone who can help.

After some more testing I think what is happening is the Webhook (Mailhook) and Search Module is triggering so quick that the email hasn’t fully loaded on Outlook’s end so when the Search is performed it’s not there to be found just yet - this type of issue around Outlook being slow to load them emails is exactly what lead to an automated workflow being required in the first place.

I guess I could try adding in a 10 second Sleep Module to give Outlook a chance to load but these emails are extremely time sensitive I am reluctant to add too much of a delay.

Also note I have changed the Search Configuration to not search any specific query but just to Order By Received Date Descending in an attempt to return ALL emails but then just choose the most recent one with Limit 1.

This has increased the Scenario run time from about 1-4 seconds to 10-12 seconds already without introducing a Sleep Module yet. Watching the scenario run this additional time is taken up by the Search Module running - I assume an open query is returning more information.

Edit: I’ve just ran a test run and the Scenario ran in 12 seconds but the actual time from Sending the Email to receiving a response was 68 seconds. When I had the Search Query populated I had real world response times of around 10 seconds.

Also note in all my testing the emails worked flawlessly, never returning the wrong email or replying to one they shouldn’t have. But the two real world emails received where it should have responded it didn’t. Both due to the Search Module not returning an Output Bundle.

The real world emails have about 80 emails CC’d and some spreadsheet attachments - not more than 500kb total. Could the number of CC’d emails be slowing down the email appearing in searches?

Hi @TF-Medforce

It seems like the timing of triggers is causing the Search Module to miss some emails, possibly because they’re not fully loaded in Outlook yet.

To tackle this, we can try adding a Sleep Module to give Outlook a bit more time to process incoming emails before the Search Module kicks in. This should help ensure that the emails are fully loaded and ready to be found.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes

Hi @Msquare_Automation, thank you for the reply.

Yes I think you are right. It is unfortunate to have to add a Sleep module due to the extreme time sensitivity of this but I don’t see another way right now.

I have added a 12 second Sleep Module as shown in your screenshot and will continue to monitor its performance.

In my test of leaving the Search Module query field blank, I had a scenario which had a run time of 11 seconds which returned the wrong email in the output bundle. I will hopefully find the optimal timing of both the duration of the scenario running and sleep module to ensure enough time for the email to load, but not any longer than required as a reply must be sent faster than 60 seconds ideally.

This is very use case specific, but I am also going to explore if this process absolutely requires the exact email received to be replied to directly, OR if I can use the Create and Send Email module instead as a valid response to the request. This would element the need for a Message ID being obtained through Search and Get modules and element this issue entirely - but again this is use case specific as I will have to check with the Operations team issuing the initial emails, but just want to include all ideas here for anyone reading in the future who may not have strict requirements.