Voting Option in Microsoft Graph API

Charan Tata 1 Reputation point
2021-12-17T09:53:11.903+00:00

Do we have voting Option in Microsoft Graph API.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,485 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeremy Thake 6 Reputation points Microsoft Employee
    2021-12-17T22:44:15.83+00:00

    You can do this through singleValueExtendedProperties.

    There is more on how to create these here https://learn.microsoft.com/en-us/graph/api/singlevaluelegacyextendedproperty-post-singlevalueextendedproperties?view=graph-rest-1.0

    Depending on your language you are using you'll have to tweak it based on the prop.id of "Binary {00062008-0000-0000-C000-000000000046} Id 0x00008520".

    There is a stackoverflow answer using the JavaSDK here https://stackoverflow.com/questions/68667907/send-exchange-email-with-voting-buttons-using-ms-exchange-graph-api-java-sdk/68668010#68668010

    Code copied here for archival

    // send an email
    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;  
    
    EmailAddress emailAddress = new EmailAddress();  
    emailAddress.address = to;  
    Recipient toRecipient = new Recipient();  
    toRecipient.emailAddress = emailAddress;  
    message.toRecipients = List.of(toRecipient);  
    
    EmailAddress fromAddress = new EmailAddress();  
    fromAddress.address = sendingMailbox;  
    Recipient fromRecipient = new Recipient();  
    fromRecipient.emailAddress = fromAddress;  
    message.from = fromRecipient;  
    
    VotingButtonEncoder vbe = new VotingButtonEncoderImpl();  
    SingleValueLegacyExtendedProperty prop =  
            new SingleValueLegacyExtendedProperty();  
    prop.value = vbe.createVoteButtonsBase64String(  
            List.of("Yes, let's have lunch.", "No, thank you though."));  
    // https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxprops/e11cc753-cecf-4fdc-bec7-23304d12388a  
    prop.id = "Binary {00062008-0000-0000-C000-000000000046} Id 0x00008520";  
    List<com.microsoft.graph.options.Option> requestOptions =  
            new ArrayList<>();  
    String requestUrl = "https://graph.microsoft.com/v1.0/users/"  
            + sendingMailbox + "/microsoft.graph.sendMail";  
    SingleValueLegacyExtendedPropertyCollectionRequestBuilder builder =  
            new SingleValueLegacyExtendedPropertyCollectionRequestBuilder(  
                    requestUrl, graphClient, requestOptions);  
    List<SingleValueLegacyExtendedProperty> pageContents =  
            new ArrayList<>();  
    pageContents.add(prop);  
    SingleValueLegacyExtendedPropertyCollectionPage singleValueExtPropPage =  
            new SingleValueLegacyExtendedPropertyCollectionPage(  
                    pageContents, builder);  
    message.singleValueExtendedProperties = singleValueExtPropPage;  
    
    boolean saveToSentItems = true;  
    
    graphClient.users(sendingMailbox)  
            .sendMail(UserSendMailParameterSet.newBuilder()  
                    .withMessage(message)  
                    .withSaveToSentItems(saveToSentItems).build())  
            .buildRequest().post();  
    
    0 comments No comments