I have a question with sending email from Blackberry java development.
My application sends mail correctly, but it defaults in FROM the previously configured mail on the BlackBerry device, I don't know how to replace the header FROM for another email diferent like the email configured in the Blackberry device, I put my code below:
try {
Address() ad = new Address ("emailexample@hotmail.com", "Maria Gomez");
} Catch (AddressException e) {
try {
Store store = Session.getDefaultInstance().getStore ();
Folder [] folders = store.list (Folder.SENT);
Sentfolder folder = folders [0];
msg = new Message (sentfolder);
try {
String [] v = splitString (toField.getText (), ',', false);
toList = new Address [v.length];
for (int i = 0; i <v.length i + +)
{
toList [i] = new Address (v [i], "");
}
} Catch (AddressException e) {System.out.println (e.toString ());}
msg.addRecipients (Message.RecipientType.TO, toList);
msg.setSubject (subjectField.getText ());
msg.setContent (msgField.getText ());
msg.setFrom (ad);
if (toField.getText().compareTo("") == 0 | | fromField.getText().compareTo("")==0)
{
Dialog.alert ("ERROR: \ n Lack mail recipient \ no sender");
}
else
{
Transport.send (msg);
Dialog.alert ("the mail was sent");
subjectField.setText ("");
msgField.setText ("");
}
} Catch (MessagingException e) {
System.out.println (e.getMessage ());
Dialog.alert ("No mail was sent");
}
I try to use msg.setFrom (ad), but dosen't work, then i try using msg.setHeader ("FROM", "emailexample@gmail.com") an neither work.
Waiting for helps, Thanks.