Sunday, 11 March 2018

J2ME email class for EHS6, BGS

J2ME implementation of email protocols that can be used on EHS6 and BGS5 modules.

In this package we provide SMTP, POP3, IMAP implementation in J2ME.

Here is example code for using SMTP class for EHS6 :

protected void startApp() throws MIDletStateChangeException {
   log = createLogger(EmailTest.class, ILogger.DEBUG);   
   SmtpClient smtpClient = null;           
           
   try {               
     smtpClient = new SmtpClient("ehs6.demo@gmail.com", createLogger(SmtpClient.class,ILogger.DEBUG));
               
           
    if(!smtpClient.connected()) {   
   // MAIL_SERVER, SMTP_PORT, SSL, APN, GPRS_USER, GPRS_PASS, SMTP_USER, SMTP_PASS
                 smtpClient.open("smtp.gmail.nl",463,true,"internet","","","smtpuser","smtppass");           
   }
           
   log.log(ILogger.DEBUG, "putting message together...");
   // FROM_ADDRESS, TO_ADDRESS, SUBJECT_TEXT
    Message message = new Message("from@address", "to@address", "Email from EHS6 with SSL");
   message.beginTextMessage();           
   message.addBodyLine("EHS6 email test message");           
   message.closeMessage();
           
   smtpClient.sendMessage(message);               
           
   } catch (Exception e) {
      log.log(ILogger.ERROR, "ERR sending email!");
       e.printStackTrace();
   }
       
   finally {
     if (null != smtpClient) { try { smtpClient.close(); }
       catch (Exception ex) {     } 

     }
      smtpClient = null;
      destroyApp(true);
   }
 }

1 comment:

  1. Hi, Thanks for referring us. your blog is very informative. IoT (Internet of Things) SIM cards, also known as M2M (Machine-to-Machine) SIM cards or cellular IoT SIM cards, are specialized SIM cards designed for use in IoT devices. Unlike traditional SIM cards used in smartphones, IoT SIM cards are optimized for low-power, low-bandwidth IoT applications and typically offer features tailored to IoT deployments. Access our comprehensive library of resources by clicking here, where you'll find everything you need to know about iot sim cards, from beginner's guides to advanced strategies.

    ReplyDelete