|
| ||||||||||
| Tags: browser, internet, java, mail, operating system, programming language |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Problem in sending mail - java program
I have a concern for sending mail. The following code works perfectly in a test class or a hand. I use exactly the same code in my web application, I get much mail, but the content is HTML is misinterpreted. In short I am unable to send mail using this java program. I explored the trails related charset unsuccessfully Environment: java 1.5 Tomcat 5.0 Code: try {
String = smtp_server PARAM_SMTP_SERVER;
String sender_email = PARAM_SENDER_EMAIL;
String mail_user = PARAM_EMAIL_USER;
String mail_pwd = PARAM_EMAIL_PWD;
Properties props = System.getProperties();
props.setProperty("mail.trans.protocol", "smtp");
props.setProperty("mail.host", Smtp_server);
props.setProperty("mail.user", mail_user);
props.setProperty("mail.password", Mail_pwd);
Session session = mailSession.getDefaultInstance(props, null);
Transport trans = mailSession.getTransport("smtp");
trans.connect(smtp_server, mail_user, mail_pwd);
InternetAddress sendineadd = new InternetAddress(sender_email);
MimeMessage message = new MimeMessage(mailSession);
message.setSubject("Mail Subject");
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(stringBuffer.function toString() {
[native code]
}());
mbp1.setContent(stringBuffer.function toString() {
[native code]
}(),"text / html; charset = ISO-8859-1");
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
message.setContent(mp);
InternetAddress iad =new InternetAddress(myEmail);
message.addRecipient(Message.RecipientType.TO, Iadress);
message.setFrom(sendineadd);
trans.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
trans.close();
}catch (Exception e) {
e.printStackTrace();
} Last edited by ISAIAH : 04-01-2010 at 12:02 PM. |
|
#2
| ||||
| ||||
| Re: Problem in sending mail - java program
Hello Quote:
Quote:
Code: setDataHandler(MyDatasource) |
|
#3
| |||
| |||
| Re: Problem in sending mail - java program
Hello Thank you for your response, tested your solution without success. I tested by changing the header, such Quote:
Quote:
|
|
#4
| ||||
| ||||
| Re: Problem in sending mail - java program
Hello You can try the following part of code, may be, this will help you. Quote:
__________________ Grand Theft Auto 4 PC Video Game |
|
#5
| ||||
| ||||
| Re: Problem in sending mail - java program
Hi Alternatively you can try this code, I have not tried it at my home still you can try and reply with your answer. You must also implement your own data source, she will give the content type, content, etc. Quote:
|
|
#6
| |||
| |||
| Re: Problem in sending mail - java program
Hello everyone, And well after a good time galley, I finally found it. there is a conflict between the jar "geronimo-javamail_1.4_spec-1.3.jar geronimo-andactivation_1.1_spec-1.0.2.jar. And those of "activation.jar"And"javamail.jar". Thank you to participants. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Problem in sending mail - java program" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error message 'There was a problem sending a command to the Program' in Internet Explorer 9 | Ramanujan | Networking & Security | 5 | 02-12-2011 01:58 AM |
| Error message ‘There was a problem sending the command to the program’ while double clicking Excel 2010 file | Wave | Windows Software | 5 | 14-05-2011 10:42 AM |
| Problem sending email windows mail vista | VauGhna | Windows Vista Mail | 3 | 06-08-2010 08:40 AM |
| Problem in using regex in java program. | Kasper | Software Development | 5 | 05-03-2010 04:39 PM |
| Problem launching .sh from java program | Ash maker | Software Development | 5 | 16-01-2010 11:32 AM |