Java Graph multiple email box support

Does the IGraphClient interface for java support multiple mailbox operations? I see that the EWSClient interface exposes getMailboxes(), etc… I don’t see this in IGraphClient interface. Or is there a way to pass the mailbox in the API calls themselves. In other words graphClient.listMessages(“mailbox” + “mailfolder”)?

@mlittle4444

This is relatively new support included in API and we will keep on adding examples in documentation based on this. I have linked this thread with issue EMAILJAVA-34750 so that we may apprise you as soon as the updates will be shared.

Thank you for the reply. Does this mean the library currently only supports one mailbox per azure client-id? I just want to make sure I understand what is currently supported so I can work within that context.

@mlittle4444

We can use Resource to support multiple mailbox:

graphClient.setResource(ResourceType.Users);
graphClient.setResourceId("mailbox");
graphClient.listMessages("mailfolder")
// back to the current mailbox
graphClient.setResource(ResourceType.Me);
1 Like

I have adapted the OAuth connect to use the
this.GRANT_TYPE = ‘client_credentials’;
method (rather than the GRANT_TYPE = ‘password’).
Then used this Resource option, as shown by mlittle4444, to access a user mailbox. But then the Query feature does not appear to work [here using “apache groovy” to simplify the coding]

def gqb = new GraphQueryBuilder()
gqb.body.contains('someone@somewhere.com')
gqb.sentDate.on(new Date().plus(-60))
gqb.subject.contains('Test')

GraphMessagePageInfo msgPgInfo = client.listMessages(folderToQuery, new PageInfo(1000), **gqb.query**)

but although I get a list of emails - they are not filtered by that query. What might I be doing wrong? The MS documentation does suggest that you cannot ‘search’ another user’s mail using Graph. But that I find that hard to believe.

Hello @mbeedell,

We have created the EMAILJAVA-35133 investigation ticket to explore this issue.
Thanks.