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

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

Upvotes

Upvote

 Feb 13 2023
9 Comments (9 New)
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 https://graph.microsoft.com/v1.0/me/messages " results the mails from user and after the mail reached user's inbox ?

Comments
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 example.com before it reaches user's inbox to keep the users in example.com 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. 
https://learn.microsoft.com/en-us/exchange/mail-flow/connectors/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 EventData:ProxyHop1:PN3PR01CA0118.outlook.office365.com(2603:1096:c01:96::19), 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