Search code examples
javascriptoutlookoutlook-web-addinsoutlook-restapi

How to get rid off from angle brackets in ethernet outlook if I am adding emails by API call?


I have question. After adding my add-in to online outlook what auto adds emails from sidebar. Emails have extra naming in their names. For example: email: [email protected]
in cc field will be - [email protected]<[email protected]>

Question is why outlook added this extra <[email protected]> stuff to email? How to remove them if I am adding them by api calls?

emails with extra less than symbol

I am using office.app.js in my add-in just in case

function _getMailItem() {
            return Office.context.mailbox.item;
 }

function addRecipientPortion(listName, emails) {
            var deferred = $q.defer();
            var mailItem = _getMailItem();
            var recipientList = mailItem[listName];

            recipientList.addAsync(emails.slice(0, 100), function (asyncResult) {
                if (asyncResult.error) {
                    deferred.reject(asyncResult.error);
                } else {
                    deferred.resolve();
                }
            })

            return deferred.promise;
        }

emails acording documentation must be array of string but if they are it rises error.

if emails are in this format it works fine but it did not work in desktop outlook

email format what works aka array of objects


Solution

  • Long story short you can not. The bug was that in Desktop outlook need to add extra prm(displayName) to the object what contain email (before that it contained only emailAddress prm).

    BE AWARE!
    If emailAddress and displayName have same values then in online outlook the email will be in triangle brackets. Like so - [email protected]<[email protected]> emails in online outlook with triangle brackets