BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-04-2008, 07:42 AM   #1 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default email

Please Login to Remove!

Hi everyone.

I just want to invoke the email API with a destinary.

But when I do this :

Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES ,new MessageArguments(MessageArguments.ARG_NEW, desti, "Email", "Body"));

It launch a new screen with SMS on the top.

So I want an email and not a sms.

How can I process???
Offline  
Old 07-04-2008, 08:16 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

from developer guide (not tested but seems OK):

Code:
net.rim.blackberry.api.mail.Message m = new net.rim.blackberry.api.mail.Message();
Address a = new Address("mLi@rim.com", "Ming Li");
Address[] addresses = {a};
m.addRecipients(net.rim.blackberry.api.mail.Message.RecipientType.TO, addresses);
m.setContent("A message for you...");
m.setSubject("Email for you");

Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));
Offline  
Old 07-04-2008, 08:19 AM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I will test it and tell you if it's works
Offline  
Old 07-04-2008, 08:28 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nothing happens.
Offline  
Old 07-04-2008, 08:37 AM   #5 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

works for me on 8800 simulator (4.2.1)

Code:
		Message m = new Message();
		Address a;
		try {
			a = new Address("mLi@rim.com", "Ming Li");
			Address[] addresses = {a};
			m.addRecipients(Message.RecipientType.TO, addresses);
			m.setContent("A message for you...");
			m.setSubject("Email for you");

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));
Offline  
Old 07-04-2008, 08:46 AM   #6 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

But this send directly an email or jsut launch the email module???
Offline  
Old 07-04-2008, 08:47 AM   #7 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

It shows a new prefilled E-Mail
Offline  
Old 07-04-2008, 08:53 AM   #8 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Allright.

I will work on it.
Offline  
Old 07-04-2008, 09:16 AM   #9 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

When I try to launch what you give me,I have this :

Uncaught exception thrown - ClassCastException.

Any idea???
Offline  
Old 07-04-2008, 09:19 AM   #10 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess you are using jde 4.1.0. In that SDK there is no way to pass a Message to the MessageArguments constructor...
Offline  
Old 07-04-2008, 09:28 AM   #11 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

No I use the jde 4.3
Offline  
Old 07-04-2008, 09:38 AM   #12 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

then it should work. Are you using the right Message class? from net.rim.blackberry.api.mail.Message
Offline  
Old 07-04-2008, 09:45 AM   #13 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes I'm sure thaht is the right Message.

I will write some Sytem.out.prinln to find where the problem is
Offline  
Old 07-04-2008, 09:49 AM   #14 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

System.out.println("test mail 1");
net.rim.blackberry.api.mail.Message m = new Message();
System.out.println("test mail 2");
Address abc;
System.out.println("test mail 3");
try
{
abc = new Address("mLi@rim.com", "Ming Li");
System.out.println("test mail 4");
Address[] addresses = {abc};
System.out.println("test mail 5");
m.addRecipients(Message.RecipientType.TO, addresses);
System.out.println("test mail 6");
m.setContent("A message for you...");
System.out.println("test mail 7");
m.setSubject("Email for you");

}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("test mail 8");
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));
System.out.println("test mail 9");
}

This is my code.

I see all the test mail until the 8.

So the problem is on the invoke

Any idea??
Offline  
Old 07-04-2008, 09:53 AM   #15 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

actually both methods work for me:

Code:
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.*;
import net.rim.blackberry.api.invoke.*;
import net.rim.blackberry.api.mail.*;

public class GuiTest extends UiApplication {

	public GuiTest()
	{
		pushScreen(new MyScreen());
	}
	
	class MyScreen extends MainScreen{
		public MyScreen(){
			add(new LabelField("test"));
		}
		
	    private MenuItem _miMailInvoke = new MenuItem("invoke", 110, 10) {
	        public void run()
	        {
	        	Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(MessageArguments.ARG_NEW, "TO", "SUBJECT", "BODY"));
	        }
	    };
	    
	    private MenuItem _miMailInvoke2 = new MenuItem("invoke 2", 110, 10) {
	        public void run()
	        {
	    		Message m = new Message();
	    		Address a;
	    		try {
	    			a = new Address("mLi@rim.com", "Ming Li");
	    			Address[] addresses = {a};
	    			m.addRecipients(Message.RecipientType.TO, addresses);
	    			m.setContent("A message for you...");
	    			m.setSubject("Email for you");

	    		} catch (Exception e) {
	    			// TODO Auto-generated catch block
	    			e.printStackTrace();
	    		}

	    		Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));
	        }
	    };
	    
        protected void makeMenu(Menu menu, int instance)
        {
            menu.add( _miMailInvoke );
            menu.add( _miMailInvoke2 );
           
            super.makeMenu(menu, instance);
        }
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		GuiTest app = new GuiTest();
		app.enterEventDispatcher();
	}
}

Last edited by Ivanov : 07-04-2008 at 09:54 AM.
Offline  
Old 07-04-2008, 10:09 AM   #16 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The first method work but on my screen I have on the top Compose SMS 137.

So when I will click on send it will send an email or a sms???
Offline  
Old 07-04-2008, 10:30 AM   #17 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

So no problem.

I have only this sreen on my simulator and the right on the BB.

Thanks a lot.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.