Not able to use filter query parameter for filtering based on from address of user using 'in'

Anumalasetti, Naveen 0 Reputation points
2023-06-06T10:12:03.9566667+00:00

HI Team,

I have been working on a use case which includes to filter mail based on the from address i.e senders email. I am trying to achieve this using Mulesoft outlook 365 connector where I need to give filter query parameter.

I have tried using 'in' with filter query data parameters but getting error saying invalid filter clause. The format I am using is as follows:-

Format :- **from/emailAddress/address in ('naveen.anumalasetti@abbvie.com','abc@def.com')
**
I am getting below error "The query filter contains one or more invalid nodes.".

Can someone help out a way to filter out emails from multiple senders using 'in'.
FYI using 'eq' will make the process lengthy as if we have 100 emails to filter we need to write 100 OR conditons..so I am feeling 'in' is a correct solution to filter out a list of emails or if there is any other parameter that I can use please let me know and help me on that.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 36,896 Reputation points
    2023-06-07T08:15:21.02+00:00

    Hi @Anumalasetti, Naveen

    Filtering messages by sender list using the "in" operator is not supported. Using the "eq" operator to filter messages by sender is a standard filtering method, if you feel that this method is too redundant for filter the sender list, then you can try to use code filtering locally.

    var result = await graphClient.Me.Messages.GetAsync();
    
    String[] str = new string[] { "emailAddress 1", "emailAddress 2", "emailAddress 3", ....... };
    
    int num = 0;
    
    for (int i = 0; i < result.Value.Count; i++) {
        
        if (str.Contains(result.Value[i].From.EmailAddress.Address) ) {
          
            Console.WriteLine(JsonConvert.SerializeObject(result.Value[i].From.EmailAddress));
    
            num = num + 1;
        }
        
    }
    
    Console.WriteLine("count:" + num);
    

    Or open a support ticket with the Microsoft support team about this and see if they have a better suggestion. You can raise support ticket from:

    http://aad.portal.azure.com or https://admin.microsoft.com/#/support/requests.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.