none
Recipients.setAsync method (JavaScript API for Office) giving the error RRS feed

  • Question

  • Hi,

    I am getting below error - 

    "Uncaught Sys.ArgumentException: Sys.ArgumentException: Value does not fall within the expected range.
    Parameter name: recipients"

    Below is code snippet:-

     addressToAdd = {
                        displayName: Office.context.mailbox.userProfile.displayName,
                        emailAddress: Office.context.mailbox.userProfile.emailAddress
                    };

    Office.cast.item.toItemCompose(Office.context.mailbox.item).requiredAttendees.setAsync(addressToAdd, function (result) {
                            if (result.error) {
                                app.showNotification(result.error);
                            } else {
                                app.showNotification("Recipients overwritten");
                            }
                        });

    Immediate help is highly appreciated.

    Thank you.

    Tuesday, December 1, 2015 9:26 AM

Answers

  • Hi Sandip,

    The parameter for the Recipients.setAsync should be an array. Please use [addressToAdd] instead of addressToAdd . Here is the correct format for your reference:

     addressToAdd = {
                         displayName: Office.context.mailbox.userProfile.displayName,
                         emailAddress: Office.context.mailbox.userProfile.emailAddress
                     };
    
    Office.cast.item.toItemCompose(Office.context.mailbox.item).requiredAttendees.setAsync([addressToAdd], function (result) {
                             if (result.error) {
                                 app.showNotification(result.error);
                             } else {
                                 app.showNotification("Recipients overwritten");
                             }
                         });
    
    You can get more detail about this function from link below:

    Recipients.setAsync method (JavaScript API for Office)

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 2, 2015 2:25 AM
    Moderator
  • Hi Sandip,

    Sorry for the confusion.

    The Recipients.setAsync is right method to book the room via Mail add-in. For this issue, please check the how you build for the addressToAdd variable.

    In the original post, you were adding yourself to the recipients. If you want to book a room, we can get the room name and address via book it manually and then test it in the code.

    Hope it is helpful.

    Regards & Fei 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 7, 2015 7:00 AM
    Moderator

All replies

  • Hi Sandip,

    The parameter for the Recipients.setAsync should be an array. Please use [addressToAdd] instead of addressToAdd . Here is the correct format for your reference:

     addressToAdd = {
                         displayName: Office.context.mailbox.userProfile.displayName,
                         emailAddress: Office.context.mailbox.userProfile.emailAddress
                     };
    
    Office.cast.item.toItemCompose(Office.context.mailbox.item).requiredAttendees.setAsync([addressToAdd], function (result) {
                             if (result.error) {
                                 app.showNotification(result.error);
                             } else {
                                 app.showNotification("Recipients overwritten");
                             }
                         });
    
    You can get more detail about this function from link below:

    Recipients.setAsync method (JavaScript API for Office)

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 2, 2015 2:25 AM
    Moderator
  • Hi Fei,

    I have tried the corrected source code still getting below error.

    Actually, my scenario is - In my office add-in, On checkbox click I want to set room name in add location text box as well as Attendees list & when I uncheck the checkbox I want to remove that room name from add location text box as well as Attendees list. Below is screen shot for same. Please help me on this.

    Regards,

    Sandip 


    Wednesday, December 2, 2015 11:05 AM
  • Hi Sandip,

    Based on my understanding, the Recipients.setAsyncis used to set the recipient list for an appointment or message.

    If you want to set the room for the appointment, we can using code below:

     Office.cast.item.toAppointmentCompose(item).location.setAsync("Room1");
    
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 3, 2015 7:22 AM
    Moderator
  • Hi,

    When we use your code it will add "Room1" to "add a location" text box only. Ideally It should also add to receipient list. Otherwise it will always show as free room. It will never be booked. This is how the Out of Box "Add Room" working.

    Thank you.

    Regards,

    Sandip

    Friday, December 4, 2015 5:43 AM
  • Hi Sandip,

    Sorry for the confusion.

    The Recipients.setAsync is right method to book the room via Mail add-in. For this issue, please check the how you build for the addressToAdd variable.

    In the original post, you were adding yourself to the recipients. If you want to book a room, we can get the room name and address via book it manually and then test it in the code.

    Hope it is helpful.

    Regards & Fei 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 7, 2015 7:00 AM
    Moderator
  • Hi,

    The Recipients.setAsync is right method to add the room to attendees list via Mail add-in. That's correct.

    But, I want to clear the attendees list via Mail add-in. Please let me know if you find any solution.

    Thank you.

    Regards,

    Sandip 


    Thursday, December 31, 2015 11:17 AM
  • Hi Sandip,

    Sorry for the later responding.

    The Recipients.setAsync(recipients, optionsopt, callback) can used to overwrite the current recipient list. So we can use the code below to remove the all recipients:

     Office.cast.item.toMessageCompose(item).to.setAsync([], function (result) {
                    console.log(result.status);
                });

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 7, 2016 9:24 AM
    Moderator
  • Hi Fei,

    I have tried your code to set optionalAttedees as well as requiredAttendees i.e. overwrite the current recipient list. I havn't find anything for "to" i.e. 

    Office.cast.item.toMessageCompose(item).to.setAsync([],
     function (result) {}) 

    When tried for optionalAttedees & requiredAttendees unfortunately, I am getting below error.  

    Thank you again for your response.

    Regards,

    Sandip




    Thursday, January 7, 2016 12:17 PM
  • Hi Sandip,  Did you ever get this to work?  I am having same problem.  My Outlook compose addin calls requiredAttendees.setAsync() with code that comes straight from MSDN example and I get "InternalFormatError" returned.   Like you, I am also and looking for an API call that works like the out of the box "Add Room".  That is, I was the room added to Location field and  recipient  list.

    Thanks, Wendy

    Thursday, March 31, 2016 6:49 PM