| Author |
javax.mail.MessagingException: IOException while sending message
|
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
hi guys,
look at the code below
for test, i want to send a mail but its throwing an exception
i had tried by sending plaintext as well as html but i am unable to find where the problem resides
can anybody tell me about it please.
|
 |
Nam Ha Minh
Ranch Hand
Joined: Oct 31, 2011
Posts: 346
|
|
You should set the content object (type MimeMultipart) as to the setContent() method of the simpleMessage object (Message class).
I have written a similar thing here.
|
 |
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
hi thank you for the response
I had tried the similar what you had in your blog earlier, even for that its showing the same
exception.
|
 |
Nam Ha Minh
Ranch Hand
Joined: Oct 31, 2011
Posts: 346
|
|
Raviteja Penki wrote:hi thank you for the response
I had tried the similar what you had in your blog earlier, even for that its showing the same
exception.
Please check again, the MIME type multipart/alternative is not supported:
or post your updated code here.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Raviteja Penki wrote:
Why don't you just use simpleMessage.setContent(content);? The method is overloaded to take a Multipart, and that's exactly what content is.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
hi guys, thank you for the response, i had tried those too, even then same exception.
this was the initial code, my IDE is Eclipse, is there any problem with that ?
can anybody tell me whats the meaning of the exception.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
If you're getting the same exception as in your original post -- the one which mentioned multipart/alternative -- from that code, which doesn't use multipart messages at all, then you have a fundamental usage problem. Namely you aren't running the code you think you are running.
|
 |
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
hi
sorry, i didn't understand what you said.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
In your last piece of code you only use a simple mail body, no multipart. If you still get an error about MIME type multipart/alternative that means that either your class files are not up-to-date, or you aren't running the code you think you are running (e.g. a different class).
|
 |
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
i had tried with the two types of code and in two scenarios i got the same exception.
in the first attached piece of code i had used multipart
where as in the second attachment i didn't use it because i am trying to send just a plain text, for that i no need to mention about multipart.
and in all scenarios, mail is delivering but not the content and subject.
i am sure about which class i'm running.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Raviteja Penki wrote:i had tried with the two types of code and in two scenarios i got the same exception.
in the first attached piece of code i had used multipart
where as in the second attachment i didn't use it because i am trying to send just a plain text, for that i no need to mention about multipart.
and in all scenarios, mail is delivering but not the content and subject.
i am sure about which class i'm running.
This is getting even more confusing. In both cases you get the exception about multipart/alternative? But in spite of getting an exception, an e-mail message is still sent? In both cases? This all sounds extremely unlikely to me. So right now I don't believe any of it. Could I suggest that you document what is happening in a less confusing way? More details would help, and a less disorganized way of describing your tests would help too.
|
 |
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
sorry for improper explanation in the last post.
In the two types of code i had attached, only a mail is delivering with out the subject and content.
for sending a plain mail in the sense only text type of mail with out HTML content, i think there is no need of specifying MULTIPART, am i right?
|
 |
Nam Ha Minh
Ranch Hand
Joined: Oct 31, 2011
Posts: 346
|
|
Raviteja Penki wrote:
for sending a plain mail in the sense only text type of mail with out HTML content, i think there is no need of specifying MULTIPART, am i right?
Yes, that's correct!
|
 |
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
but, if i send like that,
the content is not delivering.
|
 |
Nam Ha Minh
Ranch Hand
Joined: Oct 31, 2011
Posts: 346
|
|
Raviteja Penki wrote:
but, if i send like that,
the content is not delivering.
For better help, could you re-post your latest code here?
|
 |
Raviteja Penki
Greenhorn
Joined: Oct 27, 2011
Posts: 19
|
|
this is the code,
i had attached the exceptions too in the earlier posts, look at those once.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Excellent idea! Now implement the second part of the idea: look at the debug output.
|
 |
Nam Ha Minh
Ranch Hand
Joined: Oct 31, 2011
Posts: 346
|
|
|
You are still missing the method to set content for the message body.
|
 |
 |
|
|
subject: javax.mail.MessagingException: IOException while sending message
|
|
|