function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VarunCVarunC 

Unable to read Email address and Subject of selected Email in Emails Application Pane Component

Following up on the provided example from documentation - Create Components for Lightning for Outlook (Beta), I am able to display the selecetd email's data in html form, but when I try to read the same variables in INIT JS controller method, I get undefined/null values.

sampleOutlookComponent.cmp
<aura:component implements="clients:availableForMailAppAppPage,clients:hasItemContext">

    <aura:attribute name="source" type="String" access="global" />
    <aura:attribute name="people" type="Object" access="global" />
    <aura:attribute name="subject" type="String" access="global" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <div id="content">
        <h1><b>Email subject</b></h1>
        <span id="subject">{!v.subject}</span>

        <h1>To:</h1>
        <aura:iteration items="{!v.people.to}" var="to">
            {!to.name} - {!to.email} <br/>
        </aura:iteration>

        <h1>From:</h1>
        {!v.people.from.name} - {!v.people.from.email}

        <h1>CC:</h1>
        <aura:iteration items="{!v.people.cc}" var="cc">
            {!cc.name} - {!cc.email} <br/>
        </aura:iteration>

        <span class="greeting">{!v.greeting}</span>, {!v.subject}!
    </div>
</aura:component>

sampleOutlookComponentController.js
({
    doInit : function(component, event, helper) {
        var sc = component.get('v.source');
        var sb = component.get('v.subject');
        var pp = component.get('v.people');
        console.log('== people [S] == ');
        console.log('Source: '+sc);
        console.log('Subject: '+sb);
        console.log(pp);
        console.log('== people [E] == ');
    }
})

The console output from above code snippet is this:
== people [S] == 
Source: undefined
Subject: undefined
null
== people [E] ==

I am unable to figure out what I'm doing incorrectly to read the selected email's attributes? Though when I launch this component in sidebar I do get the displayed html render the values correctly like this:
 
Email subject
Another Email
To:
Varun C - testing@testing123.onmicrosoft.com
From:
Varun C - testemailfrom@yahoo.com
CC:

, Another Email!


What could be wrong in my doInit method code that I'm getting null values but when I put same attribute values in component html, and it renders the values correctly, could it be a bug or I'm missing something here?



 
_Zach Boyd_Zach Boyd
The documentation specifies that the attributes are added automatically to your component. If you are redefining them then you might be overwriting the value. Could you try removing and see what happens? Also, it does use events to handle value changes. Not sure if you will need those or not.
VarunCVarunC
Well, removing the attributes did not have any effect, I'm still getting null in Init Handler.

But, adding the change handlers for People and Subject had some positive outcome. Under Subject change handler function I could get all three parameter values while under People change handler I could get values for only People attribute.