This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Problem at sending  email Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Problem at sending  email" Watch "Problem at sending  email" New topic
Author

Problem at sending email

madhuri akhi
Greenhorn

Joined: Sep 18, 2006
Posts: 24
Please if it know the solution replay to me
this is my context.html

<bean id="Connectmail" class="com.nanna.ConnectMail">
<property name="sessionForm"><value>true</value></property>
<property name="commandName"><value>formbean</value></property>
<property name="commandClass"><value>com.nanna.FormBean</value></property>
<property name="mailSender"><ref bean="mailSender"/></property>
<property name="message"><ref bean="mailMessage"/></property>
<property name="formView"><value>Home</value></property>
</bean>

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="64.79.170.116"/>
</bean>

<bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage">
<property name="from" value="support@easyuploader.com"/>
</bean>

ConnectMail.java
public class ConnectMail extends SimpleFormController{
private MailSender mailSender;
private SimpleMailMessage message;
String to_user="";
String content="";


public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
throws ServletException,Exception {

to_user=((FormBean)command).getUserid();
content=((FormBean)command).getContent();
System.out.println("to_user"+to_user);
System.out.println("content"+content);
//to_user ="user";
//content = "content";
Map myModel = new HashMap();
myModel.put("to_user", to_user);
myModel.put("content", content);
boolean temp=sendMail(to_user,content);
System.out.println(temp);
return new ModelAndView("show");
}





public boolean sendMail(final String to_user,final String content) throws MessagingException {



MimeMessagePreparator preparator = new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setRecipient(Message.RecipientType.TO,
new InternetAddress(to_user));
mimeMessage.setFrom(new InternetAddress("support@easyuploader.com"));
mimeMessage.setText(content);
}
};
try{

mailSender.send((SimpleMailMessage) preparator);
}
catch(MailException ex) {
//log it and go on
System.err.println(ex.getMessage());
}

return true;
}
public MailSender getMailSender() {
return mailSender;
}


public void setMailSender(MailSender mailSender) {
this.mailSender = mailSender;
}


public SimpleMailMessage getMessage() {
return message;
}


public void setMessage(SimpleMailMessage message) {
this.message = message;
}
}

at the time of running am getting java.lang.ClassCastException

if it know how can it solve

from
madhuri
 
 
subject: Problem at sending email
 
Similar Threads
Sending a X509Certificate with JavaMail attachment
Configuring Email Sending with Spring
Can we attach multiple email addresses through spring email
sending emil with spring mail abstact layer
problem sending mail with spring javamailsender