to get ip address from contacts or inbox in gmail

2019-09-07 02:59发布

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.

2条回答
萌系小妹纸
2楼-- · 2019-09-07 03:12

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 ?

查看更多
We Are One
3楼-- · 2019-09-07 03:23

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);
    }
  } 
查看更多
登录 后发表回答