Solved

JavaMail message - removing 2 last characters

Posted on 2004-09-13
29
213 Views
Last Modified: 2013-11-24
Hi!
Have you encountered the problem that the last 2 characters were removed from your message?
I'm using javamail 1.3
Thanks
0
Comment
Question by:rzvika2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
  • 4
  • +2
29 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 12045054
No.  Can you post your code?
0
 

Author Comment

by:rzvika2
ID: 12045206
I'ts a regular and simple code, not something special,
actually, when I send it to one address the text is ok, but when I send it to another, it remove the last two chars.
If I send to the problematic email address a mail from yahoo, for example, it gets the message in the right way.
The code is something similar to this:

          Message msg = new MimeMessage(session);
          msg.setFrom(new InternetAddress(from));
          InternetAddress[] address = {new InternetAddress(args[0])};
          msg.setRecipients(Message.RecipientType.TO, address);
          msg.setSubject("JavaMail APIs Test");
          msg.setSentDate(new Date());
          // If the desired charset is known, you can use
          // setText(text, charset)
          msg.setText(msgText);
          
          Transport.send(msg);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045254
What *are* the last two characters? They may be chars not supported by the default charset
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rzvika2
ID: 12045282
they are regular chars (in my last test, it was 'xt')
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12045289
Is it always the same address that it fails on?

>          msg.setText(msgText);

what is "msgText"?

Tim
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12045321
Perhaps add two extra characters to the string :P lol
[r.D]
0
 

Author Comment

by:rzvika2
ID: 12045325
Yes, it is always the same address(es) (the same domain)
The message text is:
Text line1
Text line2

but what I get in the second line is
Text lin
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045329
Are you sure it's not some 'budget' provider truncating your message out of 'economy'?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045342
Substitute a different String and see if it gets truncated at the same offset ;-)
0
 

Author Comment

by:rzvika2
ID: 12045350
Yes, DrWarezz, I've thought of that, but try all the ways before work arounds... ;-)
0
 

Author Comment

by:rzvika2
ID: 12045361
yes, always truncated by two chars, as I've specified in the question...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045369
>>yes, always truncated by two chars, as I've specified in the question...

In that case, i'll stick to my guess above as to why ;-)
0
 

Author Comment

by:rzvika2
ID: 12045386
CEHJ, when I send this email from another mail acount (and not from my javacode) it works fine.
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12045411
Have you tried using another SMTP server?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045448
>>CEHJ, when I send this email from another mail acount (and not from my javacode) it works fine.

Hmm. That's weird. How are you setting 'msgText' and what's in it?
0
 

Author Comment

by:rzvika2
ID: 12045467
no, but again, if I send the same message to 2 different emails, and only in one of them I get the message truncated, why should it be the server problem?
0
 

Author Comment

by:rzvika2
ID: 12045476
setText("Text - line1\nText - line2");
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045508
You've got me stumped ;-) Try telnetting in and see what happens when you do it manually
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12045585
Isn't there some standard where mails must end with a CR/LF?

Like when you telnet into port 25, the last line has to end with a CR/LF

Sounds to me like the mail server that fails is being a bit heavy handed with its treatment of the specification...

So as a solution, do as DrWarezz says, and just append "\n\r" to the end of any email you send...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045607
>>Isn't there some standard where mails must end with a CR/LF?

No, they must end with a dot on a line on its own. This probably has nothing to do with the problem though ;-)
0
 

Author Comment

by:rzvika2
ID: 12045639
Actually, when I append two spaces, it's ok.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12047289
> No, they must end with a dot on a line on its own. This probably has nothing to do with the problem though ;-)

Yeah, but the line of text before it would have \n\r on it ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12047339
Yes. Are we any nearer to explaining this mystery?
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12047547
Let's just blame someone, and close it :P lol
0
 

Author Comment

by:rzvika2
ID: 12047597
LOL
Just don't blame me ;-)
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12047638
lol - Who else? :P

Anyways, let's be serious now: I would put it down to being a stupid server problem.. Have you found that appending those two spaces fixes it? If so, then that's probably as close to fixing it as you're going to get  lol (atleast in my eyes).

Best of luck,
[r.D]
0
 

Author Comment

by:rzvika2
ID: 12047681
Yes, appending two spaces solves it.
Thank you all for such a good spirit!
Have fun!
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12319471
PAQed, with points refunded (100)

Computer101
E-E Admin
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question