@@ -53,13 +53,21 @@ class Main extends React.Component<MainProps, MainState> {
5353 this . loadOrReload ( ) ;
5454 }
5555
56+
5657 _connectedFlow = ( ) => {
5758 if ( ! Office . context . mailbox . item ) {
5859 return ;
5960 }
60-
61- const email = Office . context . mailbox . item . from . emailAddress ;
62- const displayName = Office . context . mailbox . item . from . displayName ;
61+
62+ // If outlook is showing the oultook user's answer, we pick the sender of the original email.
63+ // Which is most likely the first "to" address, until proven otherwise.
64+ let email = Office . context . mailbox . item . from . emailAddress ;
65+ let displayName = Office . context . mailbox . item . from . displayName ;
66+ if ( Office . context . mailbox . userProfile . emailAddress == Office . context . mailbox . item . from . emailAddress ) {
67+ email = Office . context . mailbox . item . to [ 0 ] . emailAddress ;
68+ displayName = Office . context . mailbox . item . to [ 0 ] . displayName ;
69+ }
70+
6371 this . context . setIsLoading ( true ) ;
6472
6573 const cancellablePartnerRequest = sendHttpRequest ( HttpVerb . POST , api . baseURL + api . getPartner , ContentType . Json , this . context . getConnectionToken ( ) , {
@@ -110,8 +118,16 @@ class Main extends React.Component<MainProps, MainState> {
110118 _disconnectedFlow ( ) {
111119 Office . context . mailbox . getUserIdentityTokenAsync ( idTokenResult => {
112120 const userEmail = Office . context . mailbox . userProfile . emailAddress ;
113- const senderEmail = Office . context . mailbox . item . from . emailAddress ;
114- const senderDisplayName = Office . context . mailbox . item . from . displayName ;
121+
122+ // The "sender" is the sender of the original mail.
123+ // If outlook is showing the oultook user's answer, we pick the sender of the original email.
124+ // Which is most likely the first "to" address, until proven otherwise.
125+ let senderEmail = Office . context . mailbox . item . from . emailAddress ;
126+ let senderDisplayName = Office . context . mailbox . item . from . displayName ;
127+ if ( Office . context . mailbox . userProfile . emailAddress == Office . context . mailbox . item . from . emailAddress ) {
128+ senderEmail = Office . context . mailbox . item . to [ 0 ] . emailAddress ;
129+ senderDisplayName = Office . context . mailbox . item . to [ 0 ] . displayName ;
130+ }
115131 const senderDomain = senderEmail . split ( '@' ) [ 1 ] ;
116132
117133 const partner = new PartnerData ( ) ;
@@ -185,6 +201,7 @@ class Main extends React.Component<MainProps, MainState> {
185201
186202 _getMessageBars = ( ) => {
187203 const { type, info} = this . state . EnrichmentInfo ;
204+ const message = this . state . EnrichmentInfo . getTypicalMessage ( ) ;
188205 let bars = [ ] ;
189206 if ( this . state . showPartnerCreatedMessage && this . state . partnerCreated ) {
190207 bars . push ( < MessageBar messageBarType = { MessageBarType . success } onDismiss = { this . _hidePartnerCreatedMessage } > Contact created</ MessageBar > ) ;
@@ -198,11 +215,12 @@ class Main extends React.Component<MainProps, MainState> {
198215 break ;
199216 case EnrichmentInfoType . NoData :
200217 case EnrichmentInfoType . NotConnected_NoData :
201- bars . push ( < MessageBar messageBarType = { MessageBarType . info } onDismiss = { this . _hideEnrichmentInfoMessage } > { info } </ MessageBar > ) ;
218+ bars . push ( < MessageBar messageBarType = { MessageBarType . info } onDismiss = { this . _hideEnrichmentInfoMessage } > { message } </ MessageBar > ) ;
202219 break ;
203220 case EnrichmentInfoType . InsufficientCredit :
204221 bars . push ( < MessageBar messageBarType = { MessageBarType . error } onDismiss = { this . _hideEnrichmentInfoMessage } >
205- Could not auto-complete the company: not enough credits!
222+ { message }
223+ < br />
206224 < Link href = { info } target = "_blank" >
207225 Buy More
208226 </ Link >
@@ -212,7 +230,7 @@ class Main extends React.Component<MainProps, MainState> {
212230 case EnrichmentInfoType . NotConnected_InternalError :
213231 case EnrichmentInfoType . Other :
214232 case EnrichmentInfoType . ConnectionError :
215- bars . push ( < MessageBar messageBarType = { MessageBarType . error } onDismiss = { this . _hideEnrichmentInfoMessage } > { info } </ MessageBar > ) ;
233+ bars . push ( < MessageBar messageBarType = { MessageBarType . error } onDismiss = { this . _hideEnrichmentInfoMessage } > { message } </ MessageBar > ) ;
216234 break ;
217235 }
218236 }
0 commit comments