Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > WEB SERVICE AXIS TOMCAT 5.5.9 - SEND MAIL WITH FILE

Reply
Thread Tools

WEB SERVICE AXIS TOMCAT 5.5.9 - SEND MAIL WITH FILE

 
 
Cyril
Guest
Posts: n/a
 
      06-20-2006
Hello,

I've a problem to send an email with text and file's attachment (pdf) in
my WEB SERVICE. I'm send a email but it contains nothing except the
subject And when i execute this class with a main the method send main
run. Can you help to resolve this problem thank you very much

SEE the member to send the file

private boolean sendMsgAttachFile(String _to, String _subject, String
_bodyText, String _fileName, int iddoc) {
Properties props = new Properties();
props.setProperty("mail.smtp.host", smtp);

if (elogin != null && epass != null )
{
elogin.trim();
epass.trim();
//props.setProperty("mail.smtp.auth", "true");
//Authenticator auth = new SMTPAuthenticator();
//session = Session.getDefaultInstance(props, auth);
session = Session.getDefaultInstance(props,null);
} else {
session = Session.getDefaultInstance(props,null);
}
try {
File path_name = new File(RepCryptFile + _fileName);
if (path_name.exists()) {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(emaildefault));
InternetAddress[] address ={new InternetAddress(_to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(_subject);
MimeBodyPart textPart = new MimeBodyPart();
//textPart.setHeader("Content-Transfert-Encoding", "8Bit");
textPart.setText(_bodyText);
MimeBodyPart attachFilePart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(RepCryptFile + _fileName);
attachFilePart.setDataHandler(new DataHandler(fds));

String name = selectnameoffile(Integer.toString(iddoc));
attachFilePart.setFileName(name);
Multipart mp = new MimeMultipart();
mp.addBodyPart(textPart);
mp.addBodyPart(attachFilePart);
msg.setContent(mp);
Transport.send(msg);
logger.info("The email is sent with file: " + name
+ " mess: " + _bodyText + "file protect: " + RepCryptFile + _fileName);
} else {
logger.info("Error Send Mail: The email not send \n The file
doesn't exit");
return false;
}

} catch(MessagingException ex) {
logger.fatal("Error Send Mail: ", ex);
return false;
} catch(Exception err) {
logger.fatal("Error Send Mail: ", err);
return false;
}
return true;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending XML as a String through a web service (Tomcat/AXIS)? Digital Puer Java 1 05-31-2006 11:56 PM
InvocationTargetException when calling "new Service()" in Axis web service to call another web service Michael Averstegge Java 0 01-10-2006 11:05 PM
Tomcat/Axis: new thread for each web service call? Digital Puer Java 0 06-21-2005 07:08 PM
Calling a Web Service using Axis, from within an Axis Web Service running under Tomcat hocho888 Java 1 04-29-2005 08:26 PM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* unkwb@web.de Java 0 02-23-2005 04:02 PM



Advertisments