Package net.rim.blackberry.api.mail

Examples of net.rim.blackberry.api.mail.Address


        //create a message in the sent items folder
        Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);

        Message message = new Message(folders[0]);
        Address toAdd = new Address(email,"my email");
        Address toAdds[] = new Address[1];
        toAdds[0] = toAdd;
        message.addRecipients(Message.RecipientType.TO, toAdds);
        message.setSubject(subject);
        message.setContent(mp);
        Session session = Session.getDefaultInstance();
View Full Code Here


        String[] emails = MessageUtility.split( addressString );
        Address[] addresses = new Address[ emails.length ];

        for( int i = 0; i < emails.length; i++ ) {
            try {
                addresses[ i ] = new Address( emails[ i ], emails[ i ] );
            } catch( AddressException e ) {
                addresses[ i ] = null;
            }
        }
View Full Code Here

        String s = _message.getBodyText();
        return ( s == null ) ? "" : s;
    }

    private String from() {
        Address a = null;
        try {
            a = _message.getFrom();
        } catch( MessagingException me ) {
            // do nothing
        }

        String s = ( a == null ) ? "" : a.getAddr();
        return ( s == null ) ? "" : s;
    }
View Full Code Here

                String strFrom = (String)ht.get("FROM");

                if(strFrom.indexOf("<") >= 0){
                    strFrom = strFrom.substring(strFrom.indexOf("<") + 1, strFrom.indexOf(">"));
                }
                Address from = new Address(strFrom.trim(), " ");
                msg.setFrom(from);
            }

            // FIXME: What if there is more than one To: ??
            if ((String)ht.get("TO") != null) {

                String strTo = (String)ht.get("TO");

                if (strTo.indexOf("<") >= 0) {
                    strTo = strTo.substring(strTo.indexOf("<") + 1, strTo.indexOf(">"));
                }
                Address to[] = new Address[1];
                to[0] = new Address(strTo.trim(), " ");
                msg.addRecipients(Message.RecipientType.TO, to);
            }

            /*
                while (strTo.indexOf("<") >= 0) {
View Full Code Here

            try {
                final Contact c = (Contact) _invitees.elementAt(i);
                final String name = PIMDemo.getDisplayName(c);

                if (c.countValues(Contact.EMAIL) > 0) {
                    to[i] = new Address(c.getString(Contact.EMAIL, 0), name);
                }
            } catch (final AddressException e) {
                PIMDemo.errorDialog("Address(String, String) threw "
                        + e.toString());
            }
View Full Code Here

        mp.addBodyPart(sap);
        final Folder folders[] =
                Session.getDefaultInstance().getStore().list(Folder.SENT);
        final Message message = new Message(folders[0]);
        final Address[] toAdds = new Address[1];
        toAdds[0] = new Address(email, email);
        message.addRecipients(Message.RecipientType.TO, toAdds);
        message.setContent(mp);
        message.setSubject("Message with attachment "
                + fileHolder.getFileName() + ".");
        Transport.send(message);
View Full Code Here

        // If the message was received, retrieve and display who sent the
        // message
        if (_message.isInbound()) {
            try {
                final Address from = _message.getFrom();
                String name = from.getName();
                if (name == null || name.length() == 0) {
                    name = from.getAddr();
                }

                final EditField fromField =
                        new EditField("From: ", name,
                                TextField.DEFAULT_MAXCHARS, editableStyle);
View Full Code Here

                            (TextField) fieldsByType.elementAt(fieldNo);

                    // Try to create a new address object wrapping the email
                    // address and add it to the address vector.
                    try {
                        addressVector.addElement(new Address(addressField
                                .getText(), ""));
                    } catch (final AddressException e) // Invalid address
                    {
                        BlackBerryMailDemo
                                .errorDialog("Address(String, String) threw "
View Full Code Here

     * @return The sender's name
     */
    private String getSenderName(final Message message) {
        try {
            // Extract the sender's address
            final Address address = message.getFrom();
            if (address != null) {
                // If the name isn't null retrieve the sender's first name
                String name = address.getName();
                if (name != null && name.length() > 0) {
                    final int spaceIndex = name.indexOf(" ");
                    if (spaceIndex > 0) // There is a first name
                    {
                        return name.substring(0, spaceIndex);
                    }

                    return name;
                }

                // If there is no name to display then display the email
                // account name.
                name = address.getAddr();
                final int atIndex = name.indexOf("@");
                if (atIndex != -1) {
                    return name.substring(0, atIndex);
                }
            }
View Full Code Here

TOP

Related Classes of net.rim.blackberry.api.mail.Address

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.