I’m currently working on an Email Automation project where I need to upload incoming emails to an Orchestrator Queue. Specifically, for each email, I want to store the following information:
Subject(to be used as a unique reference)
Sender(which is constant)
Email Body
Attachments(either saved or base64 encoded)
To ensure queue integrity, I’m using the Subject as the Unique Reference field for each queue item.
However, I’m trying to achieve this in the most time-efficient way possible, ideally without using a For Each loop to iterate through each email individually. Since the sender is constant, I would like to upload all relevant emails in a single operation or using a more optimized method that minimizes execution time.
My key questions are:
Is there any way to upload multiple emails (including attachments and metadata) to a queue without iterating through each one using a For Each loop?
Can Bulk Add Queue Items be used in this case with MailMessage objects, or do we need to convert the data into a DataTable or a list of dictionaries first?
Are there any external packages or custom activities available that can handle this operation more efficiently?
Since the sender is always the same, can this be factored in to reduce processing logic?
Has anyone implemented a similar approach with a focus on performance and low runtime latency?
Bulk Add Queue Items does not take MailMessage directly, as I think the easiest solution is to convert email details into a DataTable or list of dictionaries and then push all items at once. Use Subject as Reference, put Body in SpecificContent, save or encode attachments before adding, and sender can be added as a fixed field to reduce logic. This avoids looping and gives best performance.
First thing queue does not support attachments etc
Saving full main data might not be needed and also exposes the data
Better way would be to loop through emails and add the message id which is unique for each mail..and in performer you can retreive all the data you need by using get mail by if activity and message id in queue. Also bulk add can be used ..by adding all message ids to dt and then use bulk add
Can you please explain 3rd point Better way would be to loop through emails and add the message id which is unique for each mail..and in performer you can retreive all the data you need by using get mail by if activity and message id in queue. Also bulk add can be used ..by adding all message ids to dt and then use bulk add
As said depending on what you use ..as you are using outlook header is where you get it
mailmessages(0).Headers("Message-ID")
Also as @rmorgan suggested instead of adding to queue you can setup integrations ervice trigger as well which will trigger process based on subject you need when its received