Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java API
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Other JSE/JEE APIs
Mail sending error
Vt Guru
Ranch Hand
Posts: 164
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
For the past one week it works fine but recently I got error while sending mail "javax.mail.MessagingException: [EOF]". Why its so can any body help me.
the code is.
import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; import java.io.Serializable; public class Email implements Serializable{ private String host; private String from; private String To[]; private String file[]; private String msg; private String subject; Email(String to[],String sub,String Message,String file[]){ host="www.hiox.com"; from="vinoth@hiox.com"; this.To=to; subject=sub; msg=Message; this.file=file; } public boolean sendMail(){ try{ Properties props = System.getProperties(); props.put("mail.smtp.host", host); Session session=Session.getInstance(props, null); MimeMessage message=new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setText(msg); InternetAddress[] addressTo = new InternetAddress[To.length]; for (int i = 0; i <To.length; i++){ addressTo[i]=new InternetAddress(To[i]); } //InternetAddress ia[]=new InternetAddress[To.length]; message.addRecipients(Message.RecipientType.BCC,addressTo); //message.addRecipient(Message.RecipientType.TO,addressTo); //message.addRecipient(Message.RecipientType.CC,addressTo); message.setSubject(subject); MimeBodyPart messageBodyPart=new MimeBodyPart(); messageBodyPart.setText(msg); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); if(file!=null){ for(int i=0;i<file.length;i++){ messageBodyPart = new MimeBodyPart(); DataSource source=new FileDataSource(file[i]); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(file[i]); multipart.addBodyPart(messageBodyPart); message.setContent(multipart); System.out.println("attaching file"); } } Transport.send( message ); return true; } catch(Exception e){ System.out.println("exception"+e); return false; } } }
>
Java Best Practices
Linux Best Practices
Amortization Calculator
Vt Guru
Ranch Hand
Posts: 164
I like...
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I got the solution at
webpage
Java Best Practices
Linux Best Practices
Amortization Calculator
Is this the real life? Is this just fantasy? Is this a tiny ad?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Sending mail thru JAVA
how to send mail using gmail server
attachment with message....
Attachment in email not working in server
jsp mails in tomcat
Paul Wheaton's new kickstarter: Cleaning Our Rivers and Oceans - the story of the Willow Feeder
More...