tags:

views:

21

answers:

1

My Application requires me to find out whether an incoming email was BCC'd to me or am i the direct(to,cc) recipient.

I have used the SendListener and the Address class but i am still clueless how to get what i need.

Any lead would be appreciated.

Thanks n Cheers

A: 

try this

     public static String getMyEmailAddress() {
      // Shared routine to get this BlackBerry's default email address
      String emailAddress;
      try {
          Session ourSession = Session.getDefaultInstance();
          // This returns null if BB does not have a Message Service - which means next
          // instruction will get a null pointer exception.
          emailAddress = ourSession.getServiceConfiguration().getEmailAddress();
      } catch ( Exception e ) {
          emailAddress = null;
      }
      return emailAddress;
  }
  public static boolean isBCCToME(){
      String myEmailAddress =getMyEmailAddress();
      Address[] a = msg.getRecipients(Message.RecipientType.BCC);
      for (int i = 0; i < a.length; i++) {
        if(a[i].equals(myEmailAddress)){
            return true;
        }
    }
      return false;
  }
Vivart
Hi Vivart, Thanks for response. what i actually wanted was to know if i was sent a BBC copy of the mail or was i the direct recipient (through the to/cc field). your code gets me the address of the person i am BCC'ing to. i am having to do this when i am forwarding/replying to the mail, not when i am receiving the mail.
Umesh