HELPP ME PLSSSSS

pikachu1298 21 Reputation points
2022-05-19T18:41:13.293+00:00

HELP ME I AM A BEGINNER JUST STARTED CODING AND IM SO BORED SO I WANT TO USE THE MICROSOFT OUTLOOK EMAIL SDK IN MICROSOFT GRAPH AND IDK HOW TO USE IT
I USE INTELLIJ IDEA IDE FOR MY JAVA CODING
HOW DO I USE THE API????
I HAVE NO IDEA HOW TO USE REST APIS

Microsoft Security | Microsoft Graph
{count} votes

Answer accepted by question author
  1. Shivam Dhiman 6,086 Reputation points
    2022-05-20T13:28:21.353+00:00

    Hi @pikachu1298

    To Send email with JAVA SDK you can use below sample code. Reference link.

    GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();  
      
    Message message = new Message();  
    message.subject = "Meet for lunch?";  
    ItemBody body = new ItemBody();  
    body.contentType = BodyType.TEXT;  
    body.content = "The new cafeteria is open.";  
    message.body = body;  
    LinkedList<Recipient> toRecipientsList = new LinkedList<Recipient>();  
    Recipient toRecipients = new Recipient();  
    EmailAddress emailAddress = new EmailAddress();  
    emailAddress.address = "******@onmicrosoft.com";  
    toRecipients.emailAddress = emailAddress;  
    toRecipientsList.add(toRecipients);  
    message.toRecipients = toRecipientsList;  
    LinkedList<Recipient> ccRecipientsList = new LinkedList<Recipient>();  
    Recipient ccRecipients = new Recipient();  
    EmailAddress emailAddress1 = new EmailAddress();  
    emailAddress1.address = "******@onmicrosoft.com";  
    ccRecipients.emailAddress = emailAddress1;  
    ccRecipientsList.add(ccRecipients);  
    message.ccRecipients = ccRecipientsList;  
      
    boolean saveToSentItems = true;  
      
    graphClient.me()  
    	.sendMail(UserSendMailParameterSet  
    		.newBuilder()  
    		.withMessage(message)  
    		.withSaveToSentItems(saveToSentItems)  
    		.build())  
    

    For more details about Authentication and Authorization please refer to below links

    Register your App
    Get access on behalf of a user
    Get access without a user
    Install the Microsoft Graph Java SDK
    MS Graph Java SDK Github

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

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. pikachu1298 21 Reputation points
    2022-06-04T12:16:50.327+00:00

    ne- nevermind

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.