Results 1 to 14 of 14
  1. #1
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default Formatting String

    Hi

    I have a program that sends automatic email. Now I have to make certain part of the text of the email bold. But i am not using awt or swing in this particular program infact it runs in the background so i can not use GUI. Is there any solution to my problem.

    Thanks

    Sachin

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  3. #3
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    Hi Fubarable

    Thanks for replying. The code is written in java and with a specific event an email has to be sent but certain part of the email text has to be bold.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I think that I understood what you are saying, but I'm not sure you are understanding me. email is text, pure and simple. You can't "bold" text unless the receiving program has a way of reading whatever you are using to format the text with.

  5. #5
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    You see when the email is sent with text in bold letters then when the email is recieved it will be in bold letters rite. So now the thing is that i have to make my text bold then automatically the email be recived in bold letters

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You understand that email consists of nothing but text, right? If you wish to "bold" text, you can do this if you use HTML mark-up and if the reading program is set to read and allow HTML formatting. I feel that I'm right here (but am not an "email" pro -- so any corrections are welcome). If I am right, I don't know how to explain this to you in any other way that is understandable.

    Please let me know if this is misleading in any way or if you (or anyone else) feels I am mistaken in my assumptions and how. I'm willing to learn.
    Last edited by Fubarable; 10-20-2009 at 07:37 PM.

  7. #7
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    Yes I know so that is what I want to do with a program. I am sure there must be a way of doing this. I mean if I have to send an email through java program and make the text of email bold then Java should have an answer for this??????

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    perhaps you wish to Google how to add HTML markup to strings using Java. I don't do this myself, but I'm sure that it is eminently possible.

  9. #9
    literallyjer is offline Member
    Join Date
    Oct 2009
    Posts
    25
    Rep Power
    0

    Default

    ersachinjain,

    Here is an example of what Fubarable is talking about:

    String message = "This is my email message. I am feeling <b>bold</b>today!";

    Do you see how the word "bold" is marked up with HTML? By doing this, email clients will notice the markup and display any text between <b> and </b> in bold.

  10. #10
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    Hi literallyjer

    Thanks for the example. I have tried this also. For eg. my text is stored in the string strtemp. So I am doing like this strtemp = "<b>" + strtemp + "</b>". even then it is nt working. Infact it is concatanating those tags to the email message:(

    Sachin

  11. #11
    literallyjer is offline Member
    Join Date
    Oct 2009
    Posts
    25
    Rep Power
    0

    Default

    Quote Originally Posted by ersachinjain View Post
    Hi literallyjer

    Thanks for the example. I have tried this also. For eg. my text is stored in the string strtemp. So I am doing like this strtemp = "<b>" + strtemp + "</b>". even then it is nt working. Infact it is concatanating those tags to the email message:(

    Sachin
    As it should. It is up to the email client to parse those tags and display the text in bold. If you are simply printing the string to the console, then the HTML tags will still show because the console does not know how to parse them.

  12. #12
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    No no I am not printing them on console i am sending them as a text of an email. When you say that it is upto the email client to parse those tags do you mean that the email server that is recieving my emails will have to parse so for eg if i am sending the email to say gmail the email server of gmail has to parse those tags.

    Thanks

  13. #13
    literallyjer is offline Member
    Join Date
    Oct 2009
    Posts
    25
    Rep Power
    0

    Default

    Quote Originally Posted by ersachinjain View Post
    No no I am not printing them on console i am sending them as a text of an email. When you say that it is upto the email client to parse those tags do you mean that the email server that is recieving my emails will have to parse so for eg if i am sending the email to say gmail the email server of gmail has to parse those tags.

    Thanks
    The email server does not parse the HTML tags.

    After some careful thought, I realized that you need to specify that you are sending HTML in an email, rather then just plain text. Look up "sending html in an email java" in Google and see what you can find.

  14. #14
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    Hi literallyjer

    [I] have finaly managed the bold and underline part. thanks a lot for your help.

Similar Threads

  1. formatting..
    By sireesha in forum New To Java
    Replies: 16
    Last Post: 06-26-2009, 08:11 PM
  2. Formatting a toString
    By MooNinja in forum New To Java
    Replies: 8
    Last Post: 03-31-2009, 08:32 PM
  3. Formatting time and date
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:35 PM
  4. formatting String
    By bugger in forum New To Java
    Replies: 1
    Last Post: 11-16-2007, 08:27 PM
  5. Formatting the date
    By yuchuang in forum New To Java
    Replies: 5
    Last Post: 05-07-2007, 07:08 PM

Posting Permissions

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