Re: Is there any way to send an Email with an attachment !
It is more involved.See below example. Note: What is missing below is setting the actual map object which I believe is correct as : map = new URLName("c:\\windows\\windows.gif"); Note: there are other constructors as wellsee the docs. - Insert the Multipart object into the Message object by calling setContent(Multipart) within a newly-constructed Message object. The example below creates a Multipart object and then adds two message parts to it. The first message part is a text string, Spaceport Map, and the second contains a document of type application/postscript. Finally, this multipart object is added to a MimeMessage object of the type described above. After all message parts are created and inserted, call the saveChanges methodto ensure that the client writes appropriate message headers. This is identical to the process followed with a single part message. Note that the JavaMail API calls the saveChanges method implicitly during the send process, so invoking it is unnecessary and expensive if the message is to be sent immediately. // Instantiate a Multipart object MimeMultipart mp = new MimeMultipart(); // create the first bodypart object MimeBodyPart b1 = new MimeBodyPart(); // create textual content // and add it to the bodypart object b1.setContent("Spaceport Map","text/plain"); mp.addBodyPart(b1); // Multipart messages usually have more than // one body part. Create a second body part // object, add new text to it, and place it // into the multipart message as well. This // second object holds postscript data. MimeBodyPart b2 = new MimeBodyPart(); b2.setContent(map,"application/ postscript"); mp.addBodyPart(b2); // Create a new message object as described above, // and set its attributes. Add the multipart // object to this message and call saveChanges() // to write other message headers automatically. Message msg = new MimeMessage(session); // Set message attrubutes as in a singlepart // message. msg.setContent(mp); // add Multipart msg.saveChanges(); // save changes -Original Message- From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of Venu Gopal Sent: Saturday, November 11, 2000 3:27 AM To: [EMAIL PROTECTED] Subject: Re: Is there any way to send an Email with an attachment ! If not JMAPI how to send attachment through email? I'm using a mailing servlet. But i'm just looking for sending the attachment through the same. Is that complex thing? Venu --- Aby Kuriakose [EMAIL PROTECTED] wrote: check dis link http://www.jguru.com/jguru/faq/view.jsp?EID=30251 they hav a sample code for sending a mail with an attach using javamail api's - Original Message - From: Bhuvaneswari Palanivel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 08, 2000 4:33 AM Subject: Is there any way to send an Email with an attachment ! Hi, I am using Java Mail API for sending mail. Is there any method or something to send a email with an attachment? Please refer some site name. Thanks, Bhuvana == = To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets == = To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets __ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one Place. http://shopping.yahoo.com/ == = To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
Re: Is there any way to send an Email with an attachment !
If not JMAPI how to send attachment through email? I'm using a mailing servlet. But i'm just looking for sending the attachment through the same. Is that complex thing? Venu --- Aby Kuriakose [EMAIL PROTECTED] wrote: check dis link http://www.jguru.com/jguru/faq/view.jsp?EID=30251 they hav a sample code for sending a mail with an attach using javamail api's - Original Message - From: Bhuvaneswari Palanivel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 08, 2000 4:33 AM Subject: Is there any way to send an Email with an attachment ! Hi, I am using Java Mail API for sending mail. Is there any method or something to send a email with an attachment? Please refer some site name. Thanks, Bhuvana === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets __ Do You Yahoo!? Thousands of Stores. Millions of Products. All in one Place. http://shopping.yahoo.com/ === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Is there any way to send an Email with an attachment !
Hi, I am using Java Mail API for sending mail. Is there any method or something to send a email with an attachment? Please refer some site name. Thanks, Bhuvana === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: Is there any way to send an Email with an attachment !
you have to make a multi-part message and set the second part of it as the file. construct the rest of the message as normal(from, to, etc.): MimeMessage msg = new MimeMessage(session); MimeBodyPart mimepart1 = new MimeBodyPart(); mbp1.setText(msgText1); MimeBodyPart mimepart2 = new MimeBodyPart(); FileDataSource fds = new FileDataSource(filename); mimepart2.setDataHandler(new DataHandler(fds)); mimepart2.setFileName(fds.getName()); Multipart multi = new MimeMultipart(); multi.addBodyPart(mimepart1); multi.addBodyPart(mimepart2); msg.setContent(multi); Bhuvaneswari Palanivel wrote: Hi, I am using Java Mail API for sending mail. Is there any method or something to send a email with an attachment? Please refer some site name. Thanks, Bhuvana === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets -- I18n group, Sun Microsystems Ireland. Phone: 8199751, x19751 === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: Is there any way to send an Email with an attachment !
check dis link http://www.jguru.com/jguru/faq/view.jsp?EID=30251 they hav a sample code for sending a mail with an attach using javamail api's - Original Message - From: Bhuvaneswari Palanivel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 08, 2000 4:33 AM Subject: Is there any way to send an Email with an attachment ! Hi, I am using Java Mail API for sending mail. Is there any method or something to send a email with an attachment? Please refer some site name. Thanks, Bhuvana === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: Is there any way to send an Email with an attachment !
http://www.jguru.com/jguru/faq/faqindex.jsp?title=Entries+In+Java%3AAPI%3AJa vaMail%3AAttachmentstopic=110904 'n for reading http://www.jguru.com/jguru/faq/view.jsp?EID=26996 - Original Message - From: Bhuvaneswari Palanivel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 08, 2000 4:33 AM Subject: Is there any way to send an Email with an attachment ! Hi, I am using Java Mail API for sending mail. Is there any method or something to send a email with an attachment? Please refer some site name. Thanks, Bhuvana === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets