Hi

sorry need add first row:
System.getProperties().put("mail.host", "mail"); // Where "mail" is mail
server

Next is full code:

    try{
            System.getProperties().put("mail.host", "mail");         //
Where "mail" is mail server
              // Establish a network connection for sending mail
            URL u = new URL("mailto:" + "P.Petrov@vtr");      // Create a
mailto: URL
            URLConnection c = u.openConnection(); // Create a URLConnection
for it

            c.setDoInput(false);                  // Specify no input from
this URL
            c.setDoOutput(true);                // Specify we'll do output
            c.connect();                             // Connect to mail host
            PrintWriter outmail =               // Get output stream to mail
host
                  new PrintWriter(new
OutputStreamWriter(c.getOutputStream()));

            // Write out mail headers.  Don't let users fake the From
address
            outmail.println("From: " + "[EMAIL PROTECTED]");   //
from email
            outmail.println("To: " + "[EMAIL PROTECTED]");          //
to email
            outmail.println("Subject: " + "text subject");             //
Subject
            outmail.println();                     // blank line to end the
list of headers

            outmail.println("row1");         // 1 row
            outmail.println("row2");         // 2 row

            // Close the stream to terminate the message
            outmail.close();
      } catch (Exception ex) {
      }

Marin.





----- Original Message -----
From: "Tripat Singh" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 14, 2000 11:12 AM
Subject: Re: Send Mail Example


> i tried this but it doesn't works for me. It throws an Unknown Host
> Exception. Have u run the example code successfully.
>
> Regards
> ----- Original Message -----
> From: "Marin Velikov" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, November 14, 2000 1:43 PM
> Subject: Re: Send Mail Example
>
>
> > Sorry
> >
> > Please replace:
> >
> > URL u = new URL("mailto:" + email);      // Create a mailto: URL
> >
> > with:
> >
> > URL u = new URL("mailto:" + ToEmailAddr);      // Create a mailto: URL
> >
> > Marin.
> >
> >
> > ----- Original Message -----
> > From: "Tripat Singh" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, November 14, 2000 8:53 AM
> > Subject: Re: Send Mail Example
> >
> >
> > > Please specify what does email stands for in
> > >
> > >  URL u = new URL("mailto:" + email);      // Create a mailto: URL
> > >
> > > regards
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "Marin Velikov" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Monday, November 13, 2000 10:33 PM
> > > Subject: Re: Send Mail Example
> > >
> > >
> > > > HI
> > > >
> > > > // Code start here:
> > > > String FromEmailAddr="[EMAIL PROTECTED];
> > > > String ToEmailAddr="[EMAIL PROTECTED]";
> > > >
> > > > String[] emailMessage = new String[3];
> > > > emailMessage[0] = "Subject:blabla ";
> > > > emailMessage[1] = "Bla bla";
> > > > emailMessage[2] = "Bla bla";
> > > >
> > > > URL u = new URL("mailto:" + email);      // Create a mailto: URL
> > > > URLConnection c = u.openConnection(); // Create a URLConnection for
it
> > > >
> > > > c.setDoInput(false);                  // Specify no input from this
> URL
> > > > c.setDoOutput(true);                  // Specify we'll do output
> > > > c.connect();                          // Connect to mail host
> > > > PrintWriter outmail =                 // Get output stream to mail
> host
> > > >           new PrintWriter(new
> OutputStreamWriter(c.getOutputStream()));
> > > >
> > > > // Write out mail headers.  Don't let users fake the From address
> > > > outmail.println("From: " + FromEmailAddr);   // from email
> > > > outmail.println("To: " + ToEmailAddr);
> > > > outmail.println(emailMessage[0]);             // Subject
> > > > outmail.println();  // blank line to end the list of headers
> > > >
> > > > outmail.println(emailMessage[1]);         // 1 row
> > > > outmail.println(emailMessage[2]);         // 2 row
> > > >
> > > > // Close the stream to terminate the message
> > > > outmail.close();
> > > >
> > > > // Code end Here.
> > > >
> > > > That's work.
> > > > Marin
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "Antonio W. Lagnada" <[EMAIL PROTECTED]>
> > > > To: <[EMAIL PROTECTED]>
> > > > Sent: Monday, November 13, 2000 6:17 PM
> > > > Subject: Send Mail Example
> > > >
> > > >
> > > > > Hello All,
> > > > >
> > > > > Does anyone have a simple example on how send an email for in JSP
or
> > > > > Servlet?
> > > > >
> > > > > Any help would be appreciated.
> > > > > Thanks
> > > > >
> > > > > --
> > > > > Antonio W. Lagnada
> > > > > Ecommerce Consultant
> > > > > [EMAIL PROTECTED]
> > > > >
> > > > > This email address is specifically
> > > > > for JSP-Interest email list.
> > > > > Remove _NOSPAM for the actual email.
> > > > >
> > > > >
> > > > >
> > > > >
___________________________________________________________________
> > > > > To get your own FREE ZDNet Onebox - FREE voicemail, email, and
fax,
> > > > > all in one place - sign up today at http://www.zdnetonebox.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
> > > >  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
> > >
> >
> >
>
===========================================================================
> > 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
>

===========================================================================
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

Reply via email to