Javax.mail Send mail vwith Israelian text
Hi, sorry for my english but i don't speak it very well....i have a problem with my class that send email....
When i send email with normal text (e.g in English) there's no problem and everything works fine....but tha problem is that i need to send email with a subject and a body in Israelian language...but when i send the email the text automatically is translated with our ASCII table (Israelian ASCII table is different)....so i think that the only way to send the text so that it remains in israelian, is to send the text in binary text (like the ftp that you can send in ASCII o BINARY.....i need to send in binary mode like the ftp)....
If someone knows how to resolve this problem please help me....i have no more idea!!!!
Thanks bye
Assuming the default language/charset on the machine you're using is set to
"Israelian", this should "just work". If it's not working, you might want to override
the default by setting the System property "mail.mime.charset" to the charset to
use. Sorry, you're going to need to know the correct charset name; I certainly don't.
You can try sending email using another mailer like Thunderbird or Outlook and see
what charset it is using.
Similar Messages
-
Problems sending email using javax.mail.*
I need to send an email from an application I am working on. I am using the features of the javax.mail package to do so. In looking at the code I am unsure why this is not working. This is my first time using this package so it might be something silly I am missing so any of your thoughts are appreciated. The code is as follows:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class EmailTester {
public static void main(String[] args) {
try {
//Set the smtp address
Properties props = new Properties();
props.put("mail.smtp.host", args[0] );
// get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
// create a message for this session
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress from =
new InternetAddress( args[1] );
InternetAddress[] to = new InternetAddress[1];
to[0] = new InternetAddress( args[2] );
msg.setFrom(from);
msg.setRecipients(Message.RecipientType.TO, to);
// set the subject and content type
msg.setSubject("subject");
msg.setContent("this is my test email", "text/plain");
// send the email
Transport.send(msg);
catch (MessagingException me) {I have an EMail class that I use at:
http://www.discoverteenergy.com/files/EMail.java
Feel free to use it or compare against your code to see what is different. -
Mail doesn't send - javax.mail.MessagingException: 250
Hello all,
I'm new to JavaMail. I actually started with it last night. I've successfully sent a number of messages, but I randomly get a strange exception for no apparent reason.
If I run the exact same code several times, it will produce this error about every 5 or 6 times:
javax.mail.MessagingException: 250 Requested mail action okay, completed
Does anyone know what might be going on? Thanks in advance for any help you might can give.
Here is the heart of my code:
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host1);
// Get session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(fromAddress));
// Set the to address
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
// Set the subject
message.setSubject(subject);
// Set the content
message.setContent(content, "text/html");
// Send message
Transport.send(message);
Below is the debugger output: (certain values have been removed for anonymity's sake)
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG: SMTPTransport trying to connect to host "xx.xx.xx.xx", port 25
DEBUG SMTP RCVD: 220 domain.company.com ESMTP MailEnable Service, Version: 1.704-- ready at 01/14/04 14:07:27
DEBUG: SMTPTransport connected to host "xx.xx.xx.xx", port: 25
DEBUG SMTP SENT: EHLO licensing
DEBUG SMTP RCVD: 502
DEBUG SMTP SENT: HELO licensing
DEBUG SMTP RCVD: 250-AUTH LOGIN
250-SIZE 5120000
250-HELP
250 AUTH=LOGIN
DEBUG SMTP: use8bit false
DEBUG SMTP SENT: MAIL FROM:<[email protected]>
DEBUG SMTP RCVD: 250 Requested mail action okay, completed
DEBUG SMTP SENT: RCPT TO:<[email protected]>
DEBUG SMTP RCVD: 250 Requested mail action okay, completed
Verified Addresses
[email protected]
DEBUG SMTP SENT: DATA
DEBUG SMTP RCVD: 250 Requested mail action okay, completed
DEBUG SMTP SENT: QUITBut I am getting that code thrown as a MessageException; the message never goes through. If you look at the debugging output compared to a message that went through, the DATA transmission commands are screwed up.
Thanks for your input, though. I think I've gotten around this by trying to resend the message. It looks like that when I get this exception the message is never sent. I have a catch that detects this exception and tries to resend up to 3 times.
Thanks,
floosh -
How do I Send HTML formatted email using class in javax.mail pkg
How do I Send HTML formatted email using javax.mail pkg class ?i mean is thr any class available in this package to do this ?
Please see
http://javaalmanac.com/egs/javax.mail/SendApp.html
for Quintessential Program to Send E-Mail.
Then substitute line
msg.setText(content);
/with this one
msg.setContent( content , "text/html");
it should do in simplest form. -
Just moved my email from Entourage to Mail. Having real problems with getting my signatures to work properly despite sending email as Rich Text.
When adding in a small company logo to the signature, PC's / windows computers only receive signature and logo as attachments.
I've tried all possible fixes I can find including getting a PC user to format the logo but no joy. Has anyone experienced this and any ideas on a fix gratefully received.Send it as html so the signature is an image source URL
-
How to send a mail with rich text content like using outlook
Hi All. I have a serious problem. When we send the mail from
outlook express or yahoo, we can send the mail with the text appearing
in the mail with bold font , with different colors, underlined etc.
If i type this kind of text in any word processor and mail that content through java mail then the message should be received by the recepient with all that bold,color and underlines etc as it is. Can anybody please help me in this case ASAP.Go to this site and download the htmlArea Javascripts. Embedd them in your HTML and it will turn your normal HTML Text Area into Rich Text Area. Your real code will include all HTML tags. For example if you select some text and make it bold , the real HTML output will look like <B>YOUR TEXT </B>. So i guess your recipient should be able to receive HTML contents.
http://www.interactivetools.com/products/htmlarea/ -
Javax.mail.internet.ParseException when trying to send a MIME message
Hi,
I am using JavaMail to send a MIME message, but I am getting the following exception:
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at javax.mail.MessagingException.<init>(MessagingException.java:34)
at javax.mail.internet.ParseException.<init>(ParseException.java:27)
at javax.mail.internet.ParameterList.<init>(Compiled Code)
at javax.mail.internet.ContentType.<init>(ContentType.java:82)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1051)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1923)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1904)
at javax.mail.Transport.send(Transport.java:101)
at FPSend.main(Compiled Code)
The problem seems to be the header of the message, specifically the class-id filed of the content-type. This is the content-type header that causes javaMail to throw that exception:
Content-Type: multipart/alternative;
boundary="------------110059296832670";
class-id=11:9sc9bnYwM87box:2680047
I think the ":" character in the class-id is causing the problem. Does anybody know if those characters are valid according to MIME standards? And if they are not valid, is there a work around this problem?
thank you!RFC 2046 doesn't mention the existence of the class-id parameter. But it does say this:Thus, a typical "multipart" Content-Type header field might look like this:
Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08j34c0p
But the following is not valid:
Content-Type: multipart/mixed; boundary=gc0pJq0M:08jU534c0p
(because of the colon) and must instead be represented as
Content-Type: multipart/mixed; boundary="gc0pJq0M:08jU534c0p"From what I see elsewhere, Class-ID is a Microsoft extension. It wouldn't be surprising to find that Microsoft uses extensions that are incompatible with the MIME standards. -
Any help on the below error would be appreciated?
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: can't determine local email address
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at com.rightworks.maildispatcher.MailDispatcher$SenderThread.sendMessage
(MailDispatcher.java, Compiled Code)
at com.rightworks.maildispatcher.MailDispatcher$SenderThread.run(MailDis
patcher.java:536)
Cannot send mail file s1io.d.xml : Sending failed;
nested exception is:
javax.mail.MessagingException: can't determine local email addressAppears to be related to specifing the mail.from input.
Works now. -
Unable to send email javax.mail.MessagingException: 553 Domain require
Hello
When sending a test message using One to One fulfillment I get the following message
unable to send email
javax.mail.MessagingException: 553 <UNSET>... Domain name required"
Has anybody got this message before? how did you resolve it?
Thank you
Kind Regards
EvaSee if there is any space in the name of the email server. If yes, remove the space and stop and start the fulfillment server.
HTH -
Javax.mail.mailexception while am trying to send the mail
Hi.
Am trying to send a mail from ADF Application am using SMTP Server to send the mail
I have added javamail.jar in my libraries
This is the code am using to send
public String send() {
// Add event code here...
String to;
to = new String();
String host = "localhost";
String from = "[email protected]";
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);
try{
MimeMessage message = new MimeMessage (session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress("to"));
message.setSubject(subj);
message.setText(body);
Transport.send(message);
System.out.println ("Sent Message Successfully");
catch(MessagingException max){
max.printStackTrace();
return null;
}Am getting the exception as below
javax.mail.MessagingException: [EOF]
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1481)
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1512)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1321)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:637)
at javax.mail.Transport.send0(Transport.java:189)
at javax.mail.Transport.send(Transport.java:118)
at view.SendMail.send(SendMail.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(Unknown Source)
at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
Could any one pls help me?
regards,
Prasad K T.This question is better asked in a java forum or JavaMail forum {forum:id=975}
Timo -
Hi,
i've a java Mail program which will send the mail thro smtp server.
when i try to execute this program im getting the error javax.mail.MessagingException: [EOF]
i've attached both code & error.
while running the program need to give the arguments
ex : java SendMail smtpserver frommailid tomailid subject body
please provide me the solution.
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class SendMail {
public static void main(String[] args) {
try
String smtpServer=args[0];
String to=args[1];
String from=args[2];
String subject=args[3];
String body=args[4];
send(smtpServer, to, from, subject, body);
catch (Exception ex)
System.out.println("Usage: java SendMail"
+" smtpServer toAddress fromAddress subjectText bodyText");
System.exit(0);
public static void send(String smtpServer, String to, String from
, String subject, String body)
try
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
msg.setSubject(subject);
msg.setText(body);
msg.setSentDate(new Date());
System.out.println("test 1--");
Transport.send(msg);
System.out.println("test 2--");
System.out.println("Message sent OK.");
catch (Exception ex)
ex.printStackTrace();
thanks for the help in advance.
regs
lal.I ran into a similar error today. I fixed it by setting up SMTP authentication because my ISP's help pages said that they would allow only SMTP authentication.
Here is what I did:
Transport transport =
mailConnection.getTransport("smtp");
transport.connect(
"hostname", "email", "password");
Transport.send(msg);
I also passed the following property while creating the session:
props.put("mail.smtp.auth", "true");
finally turning on debug helped:
session.setDebug(true);
session.setDebugOut(null);
Hope this helps -
How can I send a series of texts from my phone to my e-mail address?
I want to send a series of texts from my phone to an e-mail address but evry time I send it, it just comes through as a text rather than an e-mail.
Please help
-
Javax.mail CSV file attachment corrupt?
I'm having some trouble with attaching a file to an outgoing email, it's a CSV file and when it is uploaded/attached to the email, it becomes "corrupt". Excel will still open it but if I open it in notepad the formatting is noticeably messed up. I need it to retain all the correct return carriages and line feeds, which I believe are what are getting mingled. (Another program must read it and this formatting is messing everything up).
Here's the code:
MimeBodyPart messageBodyPart =
new MimeBodyPart();
//fill message
messageBodyPart.setText(outBoundMessage);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
if (fileAttachment != null) {
// Part two is attachment
MimeBodyPart attachment = new MimeBodyPart();
attachment.attachFile(fileAttachment);
attachment.setFileName(fileAttachment.getName());
attachment.setHeader("type", "text/csv");
multipart.addBodyPart(attachment);
// Put parts in message
message.setContent(multipart);The other parts of the message are being created and attached where necessary. My guess is that it's not transferring in binary? I've never really done this sort of thing so if anyone could lend a hand and show me how to properly attach files so they don't get altered in anyway I would greatly appreciate it.Hi,
I am sending csv file as an attachment by using below code
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class AttchmtMail
String finaldt;
public void mailAtchmt(String fname,String dt) {
String to="[email protected]";
String from = "[email protected]";
String to2="[email protected]";
String host = "xxx.xx.xxx.xxx";
// Create properties, get Session
Properties props = new Properties();
// If using static Transport.send(),
// need to specify which host to send it to
props.put("mail.smtp.host", host);
// To see what is going on behind the scene
props.put("mail.debug", "true");
Session session = Session.getInstance(props);
try {
// Instantiatee a message
Transport bus = session.getTransport("smtp");
bus.connect();
Message msg = new MimeMessage(session);
//Set message attributes
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to),new InternetAddress(to2)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("New OU's on "+dt+".");
msg.setSentDate(new Date());
// String filename= "C:/Feeds/"+finaldt+"/"+files;
String file1= fname;
File f1=new File(file1);
if(f1.exists())
setFileAsAttachment(msg, file1);
else
//setFileAsAttachment(msg,"","",info);
msg.saveChanges();
bus.sendMessage(msg, address);
bus.close();
catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
// How to access nested exceptions
while (mex.getNextException() != null) {
// Get next exception in chain
Exception ex = mex.getNextException();
ex.printStackTrace();
if (!(ex instanceof MessagingException)) break;
else mex = (MessagingException)ex;
public void setFileAsAttachment(Message msg, String filename)
throws MessagingException {
// Create and fill first part
MimeBodyPart p1 = new MimeBodyPart();
p1.setText("Dear ,\n\nPlease check the attachment " );
// Create second part
MimeBodyPart p2 = new MimeBodyPart();
// Put a file in the second part
if(!filename.equals(""))
FileDataSource fds = new FileDataSource(filename);
p2.setDataHandler(new DataHandler(fds));
p2.setFileName(fds.getName());
// Create the Multipart. Add BodyParts to it.
Multipart mp = new MimeMultipart();
mp.addBodyPart(p1);
if(!filename.equals(""))
mp.addBodyPart(p2);
} // Set Multipart as the message's content
msg.setContent(mp);
}//End of class
Madhu -
Always get the InternetAddress & javax.mail.Session error
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>
<%@ page import="java.util.*,java.io.*" %>
<%@ page contentType="text/html;charset=big5" %>
<html>
<head>
<title>JavaMail</title>
</head>
<body>
<h2>利用JavaMail來傳送電子郵件 - 附加檔案</h2>
<%
InternetAddress[] address = null;
request.setCharacterEncoding("big5");
// MultipartRequest multi = new MultipartRequest(request , "." , 5*1024*1024 , "big5");
String mailserver = "mail.dwu.edu.tw";
String From = request.getParameter("From");
String to = request.getParameter("To");
String Subject = request.getParameter("Subject");
String type = request.getParameter("Type");
String messageText = request.getParameter("Message");
String FileName = request.getParameter("FileName");
boolean sessionDebug = false;
try {
// 設定所要用的Mail 伺服器和所使用的傳送協定
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);
Message msg = new MimeMessage(mailSession);
// 設定傳送郵件的發信人
msg.setFrom(new InternetAddress(From));
// 設定傳送郵件至收信人的信箱
address = InternetAddress.parse(to,false);
msg.setRecipients(Message.RecipientType.TO, address);
// 設定信中的主題
msg.setSubject(Subject);
// 設定送信的時間
msg.setSentDate(new Date());
if (FileName != null)
File file = new File(FileName);
// 如果有附加檔案時,先將郵件內容部份先存起來
MimeBodyPart mbp1 = new MimeBodyPart();
// 設定郵件內容的型態為 text/plain 或 text/html
mbp1.setContent(messageText, type + ";charset=big5");
// 再來對檔案作處理
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(FileName);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(MimeUtility.encodeText(fds.getName(), "big5", "B"));
// 最後再將二者整合起來,當作一份郵件送出
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
else
// 若沒有檔案時,就直接存郵件內容
msg.setContent(messageText,type + ";charset=big5");
Transport.send(msg);
out.println("郵件己順利傳送");
catch (MessagingException mex)
mex.printStackTrace();
%>
</body>
</html>
==================================
i don't know why i always get the error about the type even i already add the jar file in lib folder:
InternetAddress cannot be resolved to a type
javax.mail.Session cannot be resolved to a typeWhat server are you using?
Did you follow the instructions on the JavaMail FAQ for setting up the server?
Did you restart the server? -
Bursting Java API throws an error javax.mail.internet.ParseException
Hi,
I am using the BurstingProcessorEngine API call send emails to the employees of an organization.
When i used the bursting file with the paramter of attachments to false, the email goes through. When i change the attachment parameter to yes in the bursting control file then program errors with an exception [oracle.apps.xdo.batch.DeliveryHelper][EXCEPTION] javax.mail.internet.ParseException
following is how i the bursting control file i have used
<?xml version="1.0" encoding="UTF-8" ?>
<xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi/" type="bursting">
<xapi:request select="/PAYSLIP_REPORT/PAYSLIP">
<xapi:delivery>
<xapi:email server="exchange.corp.rghent.com" port="25" from="[email protected]">
<xapi:message id="EMAIL1" to="${EMAIL}" content-type="text/html" attachment="true" subject="Test Email">
Hello,
Oracle Workflow
</xapi:message>
</xapi:email>
</xapi:delivery>
<xapi:document key="${EMPLOYEE_NUMBER}" output-type="PDF" output="${EMPLOYEE_NUMBER}.pdf" delivery="EMAIL1">
<xapi:template type="rtf" location="xdo://PAY.XXEPUSDEPADVXML_PDF.en.US/?getSource=true" filter="">
</xapi:template>
</xapi:document>
</xapi:request>
</xapi:requestset>Hi,
You need to change the output-type to lower case, ie "pdf".
Regards,
Rajeev
Maybe you are looking for
-
Keyboard button inactive with Leopard
After installing Leopard the other day, my tray open/close button on the keyboard is completely unresponsive and i can't seem to solve the issue - anyone else come across this or have any solutions? The only way to close the tray at the moment seems
-
'osql' is not recognized error
Hello all, I have been trying to get my server to switch from the standard pointBase DB over to using a fresh SQL2000 DB on another box. I am using a Win2K box and am running the WL7.0 platform. I have changed the settings in the config.xml and db_se
-
The "Apps" button has disappeared from my iTunes
I used to click on it and download app updates. Where has it gone?
-
WF_SURVEYDEMO Code (wfsrvb.sql) for Master/Detail?
Hi, I'm investigating the master/detail approach to a workflow issue I'm having. I've become somewhat familiar with the Oracle Workflow Guide, and now I'm looking for the code behind the package WF_SURVEYDEMO, but I can't find a /demo or /demo/US dir
-
Transfer of balances between 2 different g/l accounts
hey folks, I want to transfer balance from one contract accounts receivable g/l account to another. I found fp40 but I think its useless. Any ideas how can I do it? Best regards, Jack