hi peter,
i received ur mail, so happy.
do well.
keep send mail me.
Happy...... diwali.
bye from
seyala
> Hello Seyalastry,
>
> many thanks for your help!!
> I'll try the Code immediately.
>
> Thanks again,
> Peter
>
> Seyalastry Breme wrote:
> >
> > hi peter,
> > r u using tomcat server or any other?
> > if u r using tomcat server follow this
> > i have sent a code to send mail with attachment.
> > this program has sent mail perfectly.
> > but i gave my SMTP server name as "mail.ifpindia.org"
> > in "MailerBean.java" program. but u have to give
> > ur company webserver name.
> >
> > this is html part (index.html)
> > ******************
> > <html>
> > <head>
> > <style>
> > div,input,textarea { font-family:Tahoma;
> > }
> > input.std { width:200; }
> > div.frame { padding-left:20; }
> > td{color:darkviolet; font-weight:bold;
> > font-size:90%}
> >
> > </style>
> > </head>
> > <body>
> > <center><img src="../../images/animail.gif"></center>
> > <div class="frame">
> > <form action="mailer.jsp" method="post">
> > <table><tr>
> > <td>From :      <input type="text"
> > name="from" value="anupama.k@i..." class="std"></input>
> > </td></tr>
> > <tr><td>
> >
To :          <input
> > type="text" name="to" class="std"></input>
> > </td></tr>
> > <tr><td>
> > Subject :  <input type="text" name="subject"
> > class="std"></input>
> > </td></tr>
> > <tr><td>
> > <table><tr><td>
> > Message :<br>
> > <textarea rows="8" cols="50"
name="message"></textarea></td>
> > <td width=35></td>
> > <td><img src="../../images/mail31.gif"></td>
> > </tr></table></td>
> > </tr>
> > </table>
> > Browse and attach file
> > <center><input type="file" name="path" ></input>
> > <input type="submit" value="Send"></input>
> > </center>
> > </form>
> > </div>
> > </body>
> > </html>
> >
> >
> > this is jsp part(calling package)(mailer.jsp)
> > *********************************
> >
> > <%@ page language="java" %>
> > <%@ page errorPage="errorPage.jsp" %>
> >
> > <html>
> > <head>
> > <style>
> > div,input,textarea { font-family:Tahoma; font-size:9pt; }
> > input.std { width:200; }
> > div.frame { padding-left:70; color:green; }
> > </style>
> > </head>
> > <body>
> > <% String toadd=request.getParameter("to"); %>
> > <div class="frame">
> > <jsp:useBean id="mailer"
> > class="com.stardeveloper.bean.test.MailerBean">
> > <jsp:setProperty name="mailer" property="*"/>
> > <% String path=request.getParameter("path");
> >
> > if(path.length()==0)
> > path=null;
> > //out.println(path);
> >
> > mailer.sendMail(path); %>
> > </jsp:useBean>
> > <br><center>Email has been sent successfully to <%= toadd %
>.<br>
> > <br><img src="../../images/multicol.gif"><center>
> > </div>
> > </body>
> > </html>
> >
> > this is java code (sending mail package
(MailerBean.java)
> > ****************************************
> > package com.stardeveloper.bean.test;
> >
> > import java.io.*;
> > import java.util.*;
> > import java.util.Properties;
> > import javax.mail.*;
> > import javax.mail.event.*;
> > import javax.mail.internet.*;
> > import javax.activation.*;
> >
> > public final class MailerBean extends Object implements Serializable {
> >
> > /* Bean Properties */
> > private String to = null;
> > private String from = null;
> > private String subject = null;
> > private String message = null;
> > private String filepath = null;
> > public static Properties props = null;
> > public static Session session = null;
> >
> > static {
> > /* Setting Properties for STMP host */
> > props = System.getProperties();
> > props.put("mail.smtp.host", "mail.ifpindia.org");
> > session = Session.getDefaultInstance(props, null);
> >
> > }
> >
> > /* Setter Methods */
> > public void setTo(String to) {
> > this.to = to;
> > }
> >
> > public void setFrom(String from) {
> > this.from = from;
> > }
> >
> > public void setSubject(String subject) {
> > this.subject = subject;
> > }
> >
> > public void setMessage(String message) {
> > this.message = message;
> > }
> > public void setfilepath(String path) {
> > this.filepath = path;
> > }
> >
> > /* Sends Email */
> > public void sendMail(String path) throws Exception
> > {
> > filepath=path;
> >
> > if(!this.everythingIsSet())
> > throw new Exception("Could not send email.");
> > try
> > {
> > MimeMessage message = new MimeMessage(session);
> > message.setRecipient(Message.RecipientType.TO,
> > new InternetAddress(this.to));
> > message.setFrom(new InternetAddress
(this.from));
> > message.setSubject(this.subject);
> > if(filepath!=null)
> > {
> >
> > //create the message part
> > MimeBodyPart messageBodyPart= new
> > MimeBodyPart();
> > messageBodyPart.setText(this.message);
> >
> > Multipart multipart= new MimeMultipart
();
> > multipart.addBodyPart(messageBodyPart);
> > //part two is attachment
> > messageBodyPart= new MimeBodyPart();
> > DataSource source= new FileDataSource
> > (this.filepath);
> > messageBodyPart.setDataHandler(new
> > DataHandler(source));
> > //messageBodyPart.setFileName
(filepath);
> > multipart.addBodyPart(messageBodyPart);
> > message.setContent(multipart);
> > }
> > else
> > {
> > message.setText(this.message);
> > }
> >
> > Transport.send(message);
> > }
> > catch (MessagingException e)
> > {
> > throw new Exception(e.getMessage());
> > }
> > }
> >
> > /* Checks whether all properties have been set or not */
> > private boolean everythingIsSet() {
> > if((this.to == null) ||(this.from==null)||
> > (this.subject == null) || (this.message == null))
> > return false;
> >
> > if((this.to.indexOf("@") == -1) || (this.to.indexOf
(".")
> > == -1))
> > return false;
> >
> > if((this.from.indexOf("@") == -1) || (this.from.indexOf
> > (".") == -1))
> > return false;
> >
> > return true;
> > }
> > }
> >
> > u have to do under below, it is important,
> > ie. u should put program 'MailerBean.java" in the
> > directory of
> > "tomacat 4.0\webapps\examples\web-
> > inf\classes\com\stardeveloper\bean\test\MailerBean.java
> > and
> > u should put program 'mailer.jsp" in the
> > directory of
> > "tomacat 4.0\webapps\examples\jsp\mail\mailer.jsp
> >
> > u have to put html file anywhere (ie. ur project directory or u put
with
> > mailer.jsp)
> >
> > regards
> > seyalastry Breme
> >
> > > Hello,
> > >
> > > does anybody know how it's possible to pass a file automatically as
an
> > > attachement in the
> > > HREF mailto: Tag
> > > (like ?subject=......&body=....)
> > > Or is there another way i can attach a file?
> > > Any help would be greatly appreciated.
> > > Peter
> >
> > ---
> > Do you need true END-TO-END (e2e) Java Messaging (JMS)? Softwired
> > offers industry's ONLY complete 100% JMS messaging solutions for your
> > needs TODAY.
> > Visit http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%
2Dsoftwired&url=www.softwired-inc.com NOW and find
> > out more!
> > Our unique product range includes: iBus//Mobile (wireless data),
> > iBus//MessageBus (IP Multicast), iBus//MessageServer (store and
forward)
> > and much more!