• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Sending HTML format mail thru JSP

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Ranchers,
I'm doing a dynamic website using JSP and MySQL. I want to send html format mail using JSP. How can it be possible. Please send me some links or tutorials that i can get this knowledge.

Thanks in advance

regards

Aravind Prasad
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "html format mail" ?

Do you want the body of your mail to be of html type ? Have a look at the java mail API and the SMTP protocol.

Here is a tutorial

http://java.sun.com/developer/onlineTraining/JavaMail/contents.html
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankyou John Meyers,
I have looked into the JavaMail tutorial and I am not convinced with the output. I'm still getting errors while sending. I want the code for sending the mail. For that i've used this code and it is working in my localhost system, but when i uploaded to the remote server, it is not working. Can you please tell me the reason?

Here is the code


regards

Aravind Prasad
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it is working when run on your local system but not on a server, the problem could be security at the mail server. Typically mail servers only accept outgoing mail from certain senders and your JSP server is not cleared to send mail through the system you are trying to use.

Bill
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
Now i'm trying to run a simple java mail application from JavaMail API tutuorial and it is showing me errors

The code is here



and the error i'm getting is here



I've added all the jar file in the classpath. Please assist me how can i fix this problem.

Thanks in advance

regards

Aravind Prasad
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cant use "session" when its already an implicit object.

MimeMessage(HttpSession) does not exist. MimeMessage(Session) does
 
Sheriff
Posts: 67596
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has not a thing to do with JSP. Moved to Other Java APIs.
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When sending an message with html use the set content method of the MimeMessage class. i.e mimeMessage.setContent(htmlString,"text/html");

You may want to check the implementation of transport.send and smtptransport. I think it blocks until the first server in the delivery chain accepts the message for each recipient (cant remember exactly). If this is the case, sending the mail asynchronously will provide a better user experience especially in cases where a MX record points to a dead or slow server.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic