Maybe you can enlighten me, but I don't see how this actually sends an
email?
Thanks,
Gary
> -----Original Message-----
> From: Carlos Amengual [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, June 17, 1999 6:47 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Sending emails
>
> Cezar Totth wrote:
> >
> > Hi,
> >
> > I knew "mailto:" URLs are available only from within browsers (and
> perhaps
> > their included JVM, or applets), but not from any JVM.
>
> It is not a browser-only thing. Don't confuse it with "mailto:" URLs
> embedded in Web pages. I've been using it with servlets in the meantime
> between jdk1.1 and Javamail availability. Now I use Javamail.
>
> > How should I use such an URL to send e-mails from a servlet?
>
> A slightly modified cut & paste from a very simple convenience method I
> have:
>
> try
> {
> URL u = new URL("mailto:"+ to_address);
> URLConnection c = u.openConnection();
> c.setDoInput(false);
> c.setDoOutput(true);
> c.connect();
> PrintWriter out = new PrintWriter(
> new PrintWriter(new OutputStreamWriter(c.getOutputStream())));
> out.println(this.toString());
> out.println();
> out.close();
> }
> catch(Exception e)
> {
> // Your exception handling here...
> }
>
> where "this.toString()" essentially contains something like:
>
> return new StringBuffer()
> .append("From: ")
> .append(from_address)
> .append("\n")
> .append("To: ")
> .append(to_address)
> .append("\n")
> .append("Subject: ")
> .append(subject)
> .append("\n")
> .append(body)
> .toString();
>
>
> This isn't my exact code as I have omitted a hack to send messages to
> multiple recipients, but otherwise the above code has run reliably to
> me.
>
>
> Carlos
>
> __________________________________________________________________________
> _
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html