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

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