How to get FROM (sender e-mail)

128 views
Skip to first unread message

GERMAN Automotive

unread,
Dec 18, 2017, 3:50:53 PM12/18/17
to InboxSDK

How i can get sender e-mail by indboxSDK i try this:

InboxSDK.load(2, 'sdk_marcin123_e44a6df9c6').then(sdk => {
sdk.Conversations.registerThreadViewHandler(threadView => {

var tytul=threadView.getSubject();
var contact=threadView.getContacts();

//var contact=sdk.User.getFromContact();

const el = document.createElement("div");
    el.innerHTML = '<a href=fire.php?email='+ contact +'>Szukaj klienta</a>';


    threadView.addSidebarContentPanel({
        title: 'Szukaj w EU',
        iconUrl: chrome.runtime.getURL('monkey.png'),
        el
    });
});
});

But i get: Error logged: TypeError: threadView.getContacts is not a function at sdk

How i can print from e-mail and show at html link

Thanks

Chris Cowan

unread,
Dec 22, 2017, 2:48:13 PM12/22/17
to InboxSDK
getContacts() is a method on ThreadRowViews, not ThreadViews.

MessageView has a getSender() method. You'll need to call ThreadView's getMessageViews() method to get all of the MessageView instances in the thread and then you can call getSender() on them.

GERMAN Automotive

unread,
Dec 23, 2017, 10:43:41 AM12/23/17
to InboxSDK
Could you give me example ?

Chris Cowan

unread,
Dec 26, 2017, 2:05:33 PM12/26/17
to InboxSDK
Here's an example. I tweaked it to also fix the XSS issue.

sdk.Conversations.registerThreadViewHandler(threadView => {
  const firstLoadedMessage = threadView.getMessageViews()[0];
  if (!firstLoadedMessage) return;
  const contact = firstLoadedMessage.getSender();
  const anchor = document.createElement('a');
  anchor.textContent = 'Szukaj klienta';
  anchor.href = 'http://www.example.com/fire.php?email=' + contact.emailAddress;
  const el = document.createElement('div');
  el.appendChild(anchor);

  threadView.addSidebarContentPanel({
    title: 'Szukaj w EU',
    iconUrl: chrome.runtime.getURL('monkey.png'),
    el
  });
});




Note that getMessageViews() only returns the messages in the thread that are currently expanded. In a large thread, this will usually only be the last message. The last message might be a message from the local user. You may want to check both the sender and the recipients of the message and pick the first contact that's not equal to the signed-in user.

GERMAN Automotive

unread,
Jan 4, 2018, 7:10:25 AM1/4/18
to InboxSDK
Thank you

Could you tell me how i can explode TO and CC

I check its function: messageView.getRecipients();
But when i try:
    var cc= messageView.getRecipients();
    var ccc = cc.emailAdress;

I get result: undefinded

Chris Cowan

unread,
Jan 4, 2018, 1:36:26 PM1/4/18
to InboxSDK
The result of messageView.getRecipients() is an array of contact objects. You might want to use a for-of loop to loop over them and process each one.
Reply all
Reply to author
Forward
0 new messages