2

I want to read a particular thread of email and get its email ids, in to,from,cc. also I want to get their profile pictures and name to display in the addon.

I tried to get using metadata but was not able to get it

Note : I am able to get the email ids. but for some I am not getting the names. I am not able to get profile pictures for all

so i need a way by which i can get profile picture and name of all email ids

makk patel
  • 21
  • 2

2 Answers2

0

It’s only possible to get your own profile picture as you do not have permission to access someone else’s. So if you’re deploying an addon, the user will be able to see their own profile pic.

As far as getting the name, not quite sure what you mean. The full name of a contact? The name of the the person sending you the email?

To get the name of someone that’s sent you an email that’s not one of your contacts, it’s not possible. For a contact that emails you, it’s quite simple. Here is the reference for the ContactsApp: first grab the contact by the email address, and then on the contact object, there is a method to get the fullName.

https://developers.google.com/apps-script/reference/contacts/contacts-app

Ronnie Headen
  • 289
  • 1
  • 13
  • 1
    I recently came across Insightly - add on which gets the name of the sender. So it is possible to get the name of the sender, though the sender might not be a contact . – hhsb Jul 03 '18 at 12:22
0

So far it's not possible to get the profile picture. However, it's easy to get the contact name.

Here an example:

function onGmailMessage(e) {
    var messageId = e.gmail.messageId;
    var accessToken = e.gmail.accessToken;
    GmailApp.setCurrentMessageAccessToken(accessToken);
    var message = GmailApp.getMessageById(messageId);
    var name = message.getFrom(); // This function return the name of the sender
}

If you need more information about all methods that you can use just have a look to the official documentation.

vicennt
  • 3
  • 2