Read the complete article on how to create and send messages using Microsoft Graph API in Java: https://blog.aspose.com/2022/04/01/create-and-send-messages-using-microsoft-graph-api-in-java/
Last active
April 15, 2022 17:43
-
-
Save aspose-com-gists/15c98b166292e7112871f6370c036733 to your computer and use it in GitHub Desktop.
Create and Send Messages using Microsoft Graph API in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get graph client | |
IGraphClient client = GraphClient.getClient(tokenProvider); | |
// Create message object and set properties | |
MapiMessage message = new MapiMessage(); | |
message.setSubject("Subject"); | |
message.setBody("Body"); | |
message.setProperty(KnownPropertyList.DISPLAY_TO, "to@host.com"); | |
message.setProperty(KnownPropertyList.SENDER_NAME, "from"); | |
message.setProperty(KnownPropertyList.SENT_REPRESENTING_EMAIL_ADDRESS, "from@host.com"); | |
// Create message in inbox | |
MapiMessage createdMessage = client.createMessage(GraphKnownFolders.Inbox, message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get graph client | |
IGraphClient client = GraphClient.getClient(tokenProvider); | |
// Create message object and set properties | |
MapiMessage message = new MapiMessage(); | |
message.setSubject("Subject"); | |
message.setBody("Body"); | |
message.setProperty(KnownPropertyList.DISPLAY_TO, "to@host.com"); | |
message.setProperty(KnownPropertyList.SENDER_NAME, "from"); | |
message.setProperty(KnownPropertyList.SENT_REPRESENTING_EMAIL_ADDRESS, "from@host.com"); | |
// Send message | |
client.send(message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment