Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community

How to conect to microsoft exchange using API with java application?

How to conect to microsoft exchange using API with java application?



 Feb 13 2023
9 Comments (9 New)

I want to conect to microsoft exchange using API with java application run security algorithms before it reaches user's inbox. 
How can I do that the API " GET " results the mails from user and after the mail reached user's inbox ?

Brass Contributor

It sounds like you need to develop a Transport agent so you can act on messages programmatically before they are received by a user's Exchange mailbox. However, development of these agents are not supported in Exchange Online (Exchange Server 2007 and newer only) and you cannot use Graph to do something similar.

Copper Contributor

Graph Rest API provides privilages to work with single user. I have to write code for all users in specific domain. 
I want to read and modify the messages for all users in domain before it reaches user's inbox to keep the users in safe from phshing emails. 

Brass Contributor

As I explained, you cannot use Graph to access emails before it hits user mailboxes. Only transport agents can do this, and you need to use the Exchange Server APIs (but not with Exchange Online).

Copper Contributor

Did I get it correct ?
It means that when I am using O365 (cloud version) then transport agents would not be able to access emails. 

Also, what will be mechanism for Exchange Online for this requirement ? 

Brass Contributor

Transport Agents can only be used with Exchange Server (on-premise, not cloud). You need Graph to access Exchange Online data, and you cannot use Graph to process emails before they are delivered to a user mailbox.

Copper Contributor

Finally, I realised that connectrors are only solution to process emails before it reaches user's mailbox. 
Can you help us with any sample code to create connector application ? 

Brass Contributor

Connectors are a good idea, but I don't have an answer for that now. I suggest you create a new post in the Power Automate Community.

Copper Contributor

I was referring to Microsoft exchnage connectors. 

I am trying to create a connector to send email from my domain to mail server in my organisation. I am facing issues and getting errors. 
Timestamp:2/21/2023 11:41:40 AM EventId:RECEIVE Source:SMTP MessageSubject:Test email for connector validation MessageId:<email address removed for privacy reasons> Recipients:email address removed for privacy reasons RecipientCount:1 RecipientStatus: SourceContext:08DB1116EDD7A340;2023-02-21T11:41:40.115Z;0 Sender:email address removed for privacy reasons, MimeParts:Att/Emb/MPt:0/0/1, MessageValue:MediumHigh, Replication:PN2P287MB0125, InboundTlsDetails:TLS=SP_PROT_TLS1_2_SERVER TLSCipher=CALG_AES_256 TLSKeyLength=256 TLSKeyExAlg=CALG_ECDH_EPHEM, CorrelationId:fc8d5329-3d92-492b-bea5-08db140098e8, FirstForestHop:PN3P287MB0114.INDP287.PROD.OUTLOOK.COM, FromEntity:Internet, DeliveryPriority:Normal, OriginalFromAddress:<>, AccountForest:INDP287A002.PROD.OUTLOOK.COM

Brass Contributor

Please post your issue to the Exchange community: Exchange - Microsoft Community Hub