title: How can I access a Teams user's email address?
body: <p>I'm trying to build a Microsoft Teams integration for an app, but I'm having some trouble getting a user's email address.</p>
  <p>I used the Microsoft Teams extension for VS Code to scaffold a basic app. I'm using the BotFramework v4 (NodeJS) on my server. I'm able to receive requests from Teams and respond to them as well.</p>
  <p>To get an user's email address, I am using the <code>TeamsInfo.getMember(context, id)</code> method, where the id is obtained from <code>context.activity.from</code> object. Unfortunately, calling this method results in a <code>RestError: Unknown</code> with a status code of 400.</p>
  <p>I'm not sure what I'm missing here. My app is registered with the Azure Active Directory and has the <code>User.Read.All</code> permission. Am I missing something here?</p>
  <p>Any help would be appreciated!</p>
  <p>For some context, I'm trying to build a Messaging Extension Action Command.</p>
  <p>Code:</p>
  <pre><code>import {
        TurnContext,
        TeamsActivityHandler,
        CardFactory,
        MessagingExtensionAction,
        TeamsInfo,
      } from 'botbuilder';
  
  export default class TeamsMessagingExtensionsActionBot extends TeamsActivityHandler {
    constructor() {
      super();
    }
  
    // @ts-ignore
    handleTeamsMessagingExtensionSubmitAction(
      context: TurnContext,
      action: MessagingExtensionAction,
    ) {
      switch (action.commandId) {
        case 'someCommand':
          return handleCommand(context, action);
        default:
          throw new Error('NotImplemented');
      }
    }
  }
  
  async function handleCommand(
    context: TurnContext,
    action: MessagingExtensionAction,
  ) {
    const card = CardFactory.heroCard(
      'Some Command',
      'We have received your command!',
    );
  
    const user = await TeamsInfo.getMember(context, context.activity.from.id);
    console.log('User:', user);
  
    const attachment = {
      contentType: card.contentType,
      content: card.content,
      preview: card,
    };
  
    return {
      composeExtension: {
        type: 'result',
        attachmentLayout: 'list',
        attachments: [attachment],
      },
    };
  }
  </code></pre>
  <p>This is the error I get when calling TeamsInfo.getMember(): <a href="https://jsonblob.com/492796fc-6ab8-11eb-ae42-d77492b0d1a3" rel="nofollow noreferrer">JSON</a></p>