2014-01-22 27 views
0
  // Global variables 
      var _Item; 
      var _MyEntities; 

      // The initialize function is required for all apps. 
      Office.initialize = function (reason) { 
       var _mailbox = Office.context.mailbox; 
       // Obtains the current item. 
       Item = _mailbox.item; 
       // Reads all instances of supported entities from the subject 
       // and body of the current item. 
       MyEntities = _Item.getEntities(); 

       // Checks for the DOM to load using the jQuery ready function. 
       $(document).ready(function() { 
       // After the DOM is loaded, app-specific code can run. 
       }); 
      } 

      // Gets instances of the Address entity on the item. 
      function myGetAddresses() 
      { 
       var htmlText = ""; 

       // Gets an array of postal addresses. Each address is a string. 
       var addressesArray = _MyEntities.addresses; 
       for (var i = 0; i < addressesArray.length; i++) 
       { 
        htmlText += "Address : <span>" + addressesArray[i] + "</span><br/>"; 
       } 

       document.getElementById("entities_box").innerHTML = htmlText; 
      } 

我使用上面的代碼來訪問電子郵件地址,但我無法在entities_box div中看到任何結果。從Outlook365項目中提取實體字符串

請建議我怎樣才能到達,cc和從它的電子郵件地址。

回答

0

實體只有在消息本身具有實體提取的情況下才可用(例如「123 Main St,New York,New York 10001」)。我會先開始調試,首先檢查地址是否已被真正檢測到(Bing地圖應用程序是否在該消息上激活?是否讓它啓用?)。然後,調用json.stringify並查看item.getEntities()實際返回的內容。這裏有一篇關於如何提取實體的文章:http://msdn.microsoft.com/en-us/library/office/fp161071(v=office.15).aspx