Solved

JavaMail message - removing 2 last characters

Posted on 2004-09-13
29
204 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
  • 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 video teaches viewers about errors in exception handling.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now