user1498615
user1498615

Reputation: 1

to get ip address from contacts or inbox in gmail

Google apps script.

How can i get ip of the email sender or from contacts in gmail contacts. I can import contact details from a group or mail threads from inbox. can i get the ip address of sender by apps script code sample?

Thanks in advance.

Upvotes: 0

Views: 963

Answers (2)

Robert Dean
Robert Dean

Reputation: 3203

This gets the originating IP from the first email thread in you inbox:

  var thread = GmailApp.getInboxThreads(0,1)[0]; // get first thread in inbox
  var message = thread.getMessages()[0]; // get first message
  var rawMessage = message.getRawContent();
  var lines = rawMessage.split('\n');
  for each(line in lines){
    if(line.substring(0,'X-Originating-IP'.length)=='X-Originating-IP'){
      Logger.log(line);
    }
  } 

Upvotes: 1

Serge insas
Serge insas

Reputation: 46802

You simply cannot do that... moreover, the IP adress of a contact is something that doesn't exist in real world, the IP a user is using depends on where the contact is doesn't it ?

Upvotes: 3

Related Questions