Office 365: How to get the user’s display name and email address in Outlook Web App

In this blog you will see how to get the user’s display name and email address in Outlook Web App.

Please refer my previous articles to create an app for Outlook Web App

Visual Studio 2013: http://www.c-sharpcorner.com/UploadFile/anavijai/office-365-how-to-create-an-app-for-outlook-2013-using-visu/

Napa Tool: http://www.c-sharpcorner.com/UploadFile/anavijai/office-365-how-to-create-an-app-for-outlook-web-app-using-n/

In this blog you will see how to get the user’s display name and email address in Outlook Web App.

AppRead folder: Home.html

  1. <body>  
  2.     <!-- Page content -->  
  3.     <div id="content-main">  
  4.         <div class="padding">  
  5.             <p><strong>Gets the user's display name and email address.</strong></p>           
  6.             <table id="details">  
  7.                 <tr>  
  8.                     <th>Display Name:</th>  
  9.                     <td id="displayName"></td>  
  10.                 </tr>   
  11.                 <tr>  
  12.                     <th>Email Address:</th>  
  13.                     <td id="emailAddress"></td>  
  14.                 </tr>               
  15.             </table>  
  16.         </div>  
  17.     </div>      
  18. </body>  

Home.js

  1. /// <reference path="../App.js" />  
  2. /*global app*/  
  3.   
  4. (function () {  
  5.     'use strict';  
  6.   
  7.     // The Office initialize function must be run each time a new page is loaded  
  8.     Office.initialize = function (reason) {  
  9.         $(document).ready(function () {  
  10.             app.initialize();  
  11.   
  12.             displayItemDetails();  
  13.         });  
  14.     };  
  15.   
  16.     // Displays the "Subject" and "From" fields, based on the current mail item  
  17.     function displayItemDetails() {  
  18.         var userProfile = Office.context.mailbox.userProfile;         
  19.         $('#displayName').text(userProfile.displayName);      
  20.         $('#emailAddress').text(userProfile.mailAddress);         
  21.     }  
  22. })();  
 Output:
 
 
Reference:

https://msdn.microsoft.com/en-us/library/fp161126.aspx

Ebook Download
View all
Learn
View all