• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Sending email attachement error in SMTP anyone can help  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am sending the email with attachement via java mail i am getting the error
Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 571 <anandavasan.srinivasan@citicorp.com>... we do not relay
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at javax.mail.MessagingException.<init>(MessagingException.java:55)
at javax.mail.SendFailedException.<init>(SendFailedException.java:76)
at javax.mail.Transport.send0(Compiled Code)
at javax.mail.Transport.send(Transport.java:81)
at mycitibanker.service.report.HtmlImageExample.main(HtmlImageExample.java:79)

I have attached the Program

// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getDefaultInstance(props, null);
// Create the message
Message message = new MimeMessage(session);
// Fill its headers
message.setSubject("Embedded Image");
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
BodyPart messageBodyPart = new MimeBodyPart();
// Create part for the image
messageBodyPart = new MimeBodyPart();
// Fetch the image and associate to part
DataSource fds = new FileDataSource(file);
messageBodyPart.setDataHandler(new DataHandler(fds));
//messageBodyPart.setHeader("Content-ID","memememe");
// Add part to multi-part
multipart.addBodyPart(messageBodyPart);
// Create 2nd part for the image
messageBodyPart = new MimeBodyPart();
// Fetch the image and associate to part
DataSource fds2 = new FileDataSource(file2);
messageBodyPart.setDataHandler(new DataHandler(fds2));
//messageBodyPart.setHeader("Content-ID","youyouyou");
// Add part to multi-part
multipart.addBodyPart(messageBodyPart);
// Associate multi-part with message
message.setContent(multipart);
transport = session.getTransport("smtp");
// Send message
transport.send(message);
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi "citi", welcome to JavaRanch.
Please change your name to comply with the naming policy to which you agreed when you registered here..


For your publicly displayed name,
use a first name, a space, and a last name.


You can change your name:
here

You can also find the naming policy:
here
Thank You!
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
citi,
If we look at the J2EE API (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/mail/SendFailedException.html) you'll notice that a SendFailedException is thrown when you attempt to send an email to addresses that are invalid.
I assume that you're catching the exception somewhere. If not, then you may want to put a try block around your code with at least one catch block that catches a SendFailedException.
Now that you're catching the exception, it's time to see which address were invalid. The SendFailedException provides a method for this purpose: getInvalidAddresses(). It returns an array of Address objects. For info on how to use those, see the API.
Good luck,
-Stu
-edited because of tag stupidity on my part
[ July 01, 2002: Message edited by: Stu Glassman ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!