简体   繁体   中英

How can i get the sender's name from a gmail?

I am developing a firefox plug-in for gmail in javascript. the application will let the user choose between some canned responses (pre-defined emails which the user will choose, when responding to a previous email). I need the sender's mail to be filled automatically so the user doesn't need to type it each time.

example:

if the user recieves a mail from "Example Name example@domain.com", when responding to the mail, the body should say something similar to the following:

dear Example Name

thank you for choosing.... .. .. .. Sincerely, Second Example

How can I make the "Example Name" (the first one) appear automatically in the body.

Thanks

I understand you wish to scrape data from a Gmail webpage.

Looking at the html for a Gmail inbox, it seems they run most variables through a minimiser, which would make me cautious about refering to id or classnames. Maybe they make a minor change tomorrow and the minimiser chooses new names for everything.

On the bright side, some attributes seem stable. Eg: role='presentation' in

<table class=​"Bs nH iY" cellpadding=​"0" role=​"presentation">​

or email= down here

<span class=​"vN Y7BVp" email=​"info@avatron.com">

...which contains the info you really want:

<div class=​"vT">​Avatron Software (info@avatron.com)​</div>​

So I would approach this by:

  1. using .getElementsByTagname('table') and then iterating through until I find one whose role=​"presentation"
  2. using [thePresentationTable].getElementsByTagname('span'), and then looping through until I find one who has an 'email=' attribute
  3. using the tree to find the Full Name textnode, eg: [theEmailSpan].firstChild, or [theEmailSpan].firstChild.firstSibling or what have you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM