• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javax.mail.MessagingException: IOException while sending message

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Raviteja Penki
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

sorry, i didn't understand what you said.
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but, if i send like that,
the content is not delivering.
 
Nam Ha Minh
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


this is the code,
i had attached the exceptions too in the earlier posts, look at those once.

 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Excellent idea! Now implement the second part of the idea: look at the debug output.
 
Nam Ha Minh
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are still missing the method to set content for the message body.
 
reply
    Bookmark Topic Watch Topic
  • New Topic