How to Send Email through Simulator in blackberry

If you are using Blackberry Java Eclipse Plugins then follow the steps.

Step-1:   a) Sending Email Without Attachment.

//Get the Store from the default mail Session.
Store store = Session.getDefaultInstance().getStore();

//retrieve the sent folder
Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];

//create a new message and store it in the sent folder
Message msg = new Message(sentfolder);
Address recipients[] = new Address[1];

try
{
recipients[0]= new Address(“testmail@gmail.com”, “testmail”);

//add the recipient list to the message
msg.addRecipients(Message.RecipientType.TO, recipients);

//set a subject for the message
msg.setSubject(“Test email”);

//sets the body of the message
msg.setContent(“This is a test email from my BlackBerry device”);

//sets priority
msg.setPriority(Message.Priority.HIGH);

//send the message
Transport.send(msg);

Dialog.alert(“Email sent successfully..”);
}

catch (Exception me)
{
System.err.println(me);
}

b) Sending Email With Attachment:-

//create a multipart
Multipart mp = new Multipart();

//data for the content of the file
String fileData = “just a simple test n just a simple test”;
String messageData = “WelCome”;

//create the file
SupportedAttachmentPart sap = new
SupportedAttachmentPart(mp,”text/txt”,”test.txt”, fileData.getBytes());

TextBodyPart tbp = new TextBodyPart(mp,messageData);

//add the message and file to the multipart
mp.addBodyPart(tbp);
mp.addBodyPart(sap);

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

Message message = new Message(folders[0]);

//add recipients to the message and send
try
{
Address toAdd = new Address(“smita.kale3789@gmail.com”,”smita”);
Address[] toAdds = new Address[1];
toAdds[0] = toAdd;
message.addRecipients(Message.RecipientType.TO,toAdds);
message.setContent(mp);
Transport.send(message);
Dialog.alert(“Email sent successfully..”);
}

catch (Exception e)
{
Dialog.inform(e.toString());
}

 

Step-2:  Follow this path

C:Eclipsepluginsnet.rim.ejde.componentpack7.0.0_7.0.0.33componentsESS

and run “load.bat” file.

fill the required things for example email id, incomming – outgoing server name. and click Load Test.The Load Test Window will open.

Step-3: Run your application.

By using this we can send our email on any account like gmail,yahoo,etc.through simulator.

Thank you.

 

 

 


Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at info@nanostuffs.com, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box