Hai Stanley Cheung,
I runned the jsp in my sever it successfully
running, and i also recived the mail, So check once
agian ur server setting. I think ur IP "localhost"
does not have the feature of Mail Sever. Check it
once.
Here "localhost" means the address of the Mailing
Server.
Best of luck
Hareesh
--- Stanley Cheung <stanley@j...> wrote: > I
tried MimeMail, but system no response with my
> code..
> Please help and advise. Thanks!
>
> ========= JavaMail1.jsp =========
> <%@ page language="java"
> import="java.util.*,java.io.*" %>
> <%@ page import="javax.mail.*" %>
> <%@ page import="javax.mail.internet.*" %>
> <%@ page import="javax.activation.*" %>
>
> <%!
> InternetAddress[] address = null ;
> %>
> <%
>
> String mailserver = "localhost";
> String From = request.getParameter("From");
> String to = request.getParameter("To");
> String Subject = request.getParameter("Subject");
> String messageText
> request.getParameter("Message");
>
> boolean sessionDebug = false;
>
> try {
>
> // Mail Setting
> java.util.Properties props = System.getProperties();
> props.put("mail.host",mailserver);
> props.put("mail.transport.protocol","smtp");
>
> // Session
> javax.mail.Session mailSession
> javax.mail.Session.getDefaultInstance(props,null);
> mailSession.setDebug(sessionDebug);
>
> // Create the message
> MimeMessage message = new MimeMessage(mailSession);
>
> // Fill its headers
> message.setSubject(Subject);
> message.setFrom(new InternetAddress(From));
> address = InternetAddress.parse(to,false);
> message.setRecipients(Message.RecipientType.TO,
> address);
> message.setSentDate(new Date());
>
> // Create your new message part
> BodyPart messageBodyPart = new MimeBodyPart();
> String htmlText = "<H1>"+messageText+"</H1>" + "<img
> src=\"cid:memememe\">";
> messageBodyPart.setContent(htmlText, "text/html");
>
> // Create a related multi-part to combine the parts
> MimeMultipart multipart = new
> MimeMultipart("related");
> multipart.addBodyPart(messageBodyPart);
>
> // Create part for the image
> messageBodyPart = new MimeBodyPart();
>
> String file = "logo.gif";
> // Fetch the image and associate to part
> DataSource fds = new FileDataSource(file);
> messageBodyPart.setDataHandler(new
> DataHandler(fds));
> messageBodyPart.setHeader("Content-ID","meme");
>
> // Add part to multi-part
> multipart.addBodyPart(messageBodyPart);
>
> // Associate multi-part with message
> message.setContent(multipart);
>
> // é??ä¿¡
> Transport.send(message);
>
> out.println("card sent!");
>
> }
> catch (MessagingException mex) {
>
> mex.printStackTrace();
> }
>
> %>
>
> ==== End of JavaMail1.jsp =====
>
>
>
>
________________________________________________________________________
For live cricket scores download Yahoo! Score Tracker
at: http://in.sports.yahoo.com/cricket/tracker.html