[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail4ME: Having a problem, getting an I/O exception


Hi Scott,

it seems the SMTP server address is missing in this line:

>             smClient = new SmtpClient(null);
>             smClient.setDebug(true);
>             smClient.open(null);                <- this one

Without a host name, the socket can't be opened, which might result in an
IOExeption (although I would expect a NullPointerException, but that depends
on the exact circumstances, I suppose).

Regards,

Jörg

----- Original Message -----
From: "Meyer Scott" <scott.meyer@sbt.siemens.com>
To: <Mail4ME@enhydra.org>
Sent: Tuesday, May 21, 2002 2:46 PM
Subject: Mail4ME: Having a problem, getting an I/O exception


> Using this code to simply send an email to my office email address:
>
>     private boolean sendHandshake() {
>         // send a handshake to the server
>         try {
>             smClient = new SmtpClient(null);
>             smClient.setDebug(true);
>             smClient.open(null);
>
>             Message msg = new
>
Message("scott.meyer@sbt.siemens.com","scott.meyer@sbt.siemens.com","Handsha
> ke");
>             smClient.sendMessage(msg);
>
>             smClient.close();
>             return true;
>         }
>         catch (MailException me) {
>             Alert altErr = new Alert("Error","A Mail Exception
> occurred",null,AlertType.ERROR);
>             altErr.setTimeout(4500);
>             display.setCurrent(altErr,lMain);
>             System.out.println(me.toString());
>             me.printStackTrace();
>         }
>         catch (javax.microedition.io.ConnectionNotFoundException nfe) {
>             Alert altErr = new Alert("Error","A Connection Not Found
> Exception occurred",null,AlertType.ERROR);
>             altErr.setTimeout(4500);
>             display.setCurrent(altErr,lMain);
>             System.out.println(nfe.toString());
>             nfe.printStackTrace();
>         }
>         catch (java.io.IOException ioe) {
>             Alert altErr = new Alert("Error","An I/O Exception
> occurred",null,AlertType.ERROR);
>             altErr.setTimeout(4500);
>             display.setCurrent(altErr,lMain);
>             System.out.println(ioe.toString());
>             ioe.printStackTrace();
>         }
>
>         return false;
>     }
>
> I get a java.io.IOException thrown.
>
> Questions:
> 1. Am I supposed to use the connected() member function when trying to
send
> a message (i.e., instead of smClient.sendMessage(msg); should I use
> if(smClient.connected()) smClient.sendMessage(msg);
>
> 2. Am I supposed to wait a period of time after making the SMTP connection
> before trying to send a message, or loop continuously until connected()
> returns true?
>
> 3. Is there some other problem with my code?
>
> Thx in advance for any help you can provide!
>
> Scott Meyer
>
> Group Operations Supervisor
> Direct #410-645-1522, Emergency Service #410-281-1212
>
>
> _______________________________________________
> Mail4ME mailing list
> Mail4ME@enhydra.org
> http://support.enhydra.org/mailman/listinfo.cgi/mail4me