?
Solved

JavaMail message - removing 2 last characters

Posted on 2004-09-13
29
Medium Priority
?
214 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
DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

 

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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 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