Results 1 to 8 of 8
  1. #1
    jeev81 is offline Member
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default read table data from javamail

    Hi,

    I am sending mail in the HTML format and I have a table with table data containing textfield for the user to enter at the receving send.The user enters the data in the coressponding textfield when replies to the email.

    I am trying to get these entered values through my java program on receing back the filled up table.I am able to detect the mail and get the contents however the entered/filled up data appears blank.I want to know if there is a way to get these table data values?.

    Thanks,

    Regards,
    Rajeev Nair.

  2. #2
    adhoc334 is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default

    I've tried something similar before. just to be sure about your situation, it sounds like you're sending an HTML page with a textfield in it through email. The user then types into the texfield and sends the email back.

    I would say your problem is the same one I had: working with textfields will require javascript when you need the contents of that textfield. this leads to an unworkable issue: javascript is disabled in email to protect the user against viruses.

    I recommend having the user reply with syntax.
    for example, a reply could be "textfield1: <text>; tetfield2: <text>; etc."

    your program can then identify a textfield (textfield1), and the user's input (<text>) by parsing the reply rather than using an actual HTML textfield.

  3. #3
    jeev81 is offline Member
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default thanks!

    hi,

    I think you are absolutely right...there is no other way of doing it than as you had mentioned.

    Talking of javascripts not working in emails.I noticed a pecuilar thing I had once created html mail with a table whose rows change color on mouseover.When I viewed the mail in mozilla thunderbird mail application I was able to see the color change when the mouse moved over the table data but in outlook express or the mailserver I couldn't see the same effect.however certain javascripts like alert etc didn't work even on mozilla thunderbird.

    However CSS scripts were working fine on both sides.

    I believe javascripts are enabled only for certain mail browser application.What is your opnion on this?

    appreciated your quick reply ..thank you.

    Regards,
    Rajeev Nair.

  4. #4
    jeev81 is offline Member
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default re:

    Hi,

    on second thought....coming back to extracting the textfield from html message I am sending through mail , I beleive when I entered the values in the textfield area the thunderbird application prompted me to enter the field name and value.

    So therefore I believe there has to be some way to extract the fieldname and value.anyways right now i am using the workaround you suggested earlier.

    Thanks,
    Rajeev

  5. #5
    adhoc334 is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default

    I'm worried the extraction method would require javascript, though. glad the other method is working out for you.

    I ran across the Google App Engine today, and for the first time in my life, I realized it was what I desperately needed: a free and reliable server for my Java applications.

    I don't know what your program's purpose is, but mine definitely would've benefited from the ability to use a server. it definitely would've been able to accomplish the task you're trying to do through email, though with a slightly steeper learning curve and a different user-end experience.

    As for using certain mail browsers, I remember looking unsuccessfully for something that can do scripting. I've seen some high-quality HTML emails, but I've never seen an interactive/dynamic one. maybe if you made your own you'd have more luck, but that'd be too time consuming and impractical if you intend to have other people use your program.

    I'm lucky: i'm usually the only one who uses my programs, so the resulting program can be as complex as I want.
    Last edited by adhoc334; 11-26-2010 at 11:20 AM.

  6. #6
    jeev81 is offline Member
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default thanks :)

    Hi,

    well thank you for all the quick responses and the main aim of the application is to devlop a webbased CRM.As soon as a client / user sends a new mail an auto-response is sent with a form to be filled to get the client information.

    When the client replies to this mail the application detects this mail and collects all the fields which would get saved along with the mail content ,thereby all future corresspondence would get saved under their respective ticket numer in database.The stored data is viewable in the main page of the application.

    thanks again,

    Regards,
    Rajeev

  7. #7
    adhoc334 is offline Member
    Join Date
    Aug 2010
    Posts
    15
    Rep Power
    0

    Default

    yea, i wouldn't go with the App Engine then. unless you think the customer would trust a link and then click on it, then trust the site and decide to fill it out.

    shouldn't be a problem if all this is professionally done (professional-looking website, link, etc.), but that's much more time consuming then parsing the response for different fields. Of course, the user might think it takes too much effort to use the syntax method.

    would definitely shoot for the syntax method first, though. best wishes!

  8. #8
    jeev81 is offline Member
    Join Date
    Nov 2010
    Posts
    11
    Rep Power
    0

    Default I did manage to get it right!!..thank u all

    Hi,

    Finally I have got it right by using jsoup class files to parse the html string content extracted from the javamail and then finding the elements and getting the data inside them.

    p.s : you can refer this

    Extract attributes, text, and HTML from elements: jsoup Java HTML parser

    for ex:
    Java Code:
    String html = "<p>An <a href='http://example.com/'><b>example</b></a> link.</p>"; 
    Document doc = Jsoup.parse(html);
    Element link = doc.select("a").first(); 
    String text = doc.body().text(); // "An example link" 
    String linkHref = link.attr("href"); // "http://example.com/"
     String linkText = link.text(); // "example"" 
    String linkOuterH = link.outerHtml();      // "<a href="http://example.com"><b>example</b></a>" 
    String linkInnerH = link.html(); // "<b>example</b>"


    My sample code :

    Java Code:
    package com.tps.examples;
    
    import org.jsoup.Jsoup;
    import org.jsoup.nodes.Document;
    
    public class Parse {
    	
    	public static void main (String args[]) {
    		
    		String html ="<HTML> <BODY><table><tr ><td ><B>SR# Details</B></td></tr><tr><td width='40%' id='contact'> Contact Name : </td><td width='60%' align='left' id='contact-1'><B>Billy West</B></td></tr><tr style='background-color:#F7FBF1'>	<td id='mail'>  Email :</td><td id='mail-1'><B>billy,,,,,</B></td>	</tr><tr style='background-color:#F7FBF1'><td >	Company :</td>	<td><B>wsinet</B></td></tr>	<tr style='background-color:#F7FBF1'><td >	Country :</td>	<td><B>America</B></td></tr><tr style='background-color:#F7FBF1'><td >	Operating System :</td>	<td><B>Win2K</B></td></tr><tr style='background-color:#F7FBF1'><td >	Product :</td>	<td><B>128 Mb </B></td></tr>	<tr style='background-color:#F7FBF1'><td >	Message :</td>	<td><B>switchover issue</B></td></tr></table></td></tr><tr><td STYLE='font-size:12px'><BR>Regards,<BR>TPS Automated Maildelivery System.</td>	</tr>	</table> </BODY></HTML>";
    		
    		Document doc = Jsoup.parse(html);
    		
    	//	String contact = doc.getElementById("mail-1").text();
    		
    		System.out.println(doc.getElementById("contact").text()+" "+doc.getElementById("contact-1").text());
    		
    	}
    
    }

    Regards,
    Jeev81
    Last edited by jeev81; 05-19-2011 at 05:43 PM.

Similar Threads

  1. Rich data table problem
    By learner23 in forum New To Java
    Replies: 1
    Last Post: 11-11-2010, 06:23 PM
  2. Replies: 1
    Last Post: 11-09-2010, 09:28 AM
  3. What do you use for saving data from table?
    By ocean in forum New To Java
    Replies: 1
    Last Post: 11-21-2009, 07:08 PM
  4. Data formatting for the <display:table>
    By yuchuang in forum Web Frameworks
    Replies: 3
    Last Post: 12-14-2007, 10:52 AM
  5. Jsf, Filtering Data In A Table
    By Freddie in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 05-11-2007, 12:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •