-1
Store store = Session.getDefaultInstance().getStore();
Folder[] folders = store.list(Folder.SENT);
Folder sentfolder = folders[0];
// Create message.
Message msg = new Message(sentfolder);
// Add TO Recipients.
Address toList[] = new Address[1];
try {
toList[0]= new Address("someemail@email.com", "Some Email");
} catch(AddressException e) {
System.out.println(e.toString());
}
try {
msg.addRecipients(Message.RecipientType.TO, toList);
} catch (MessagingException e) {
System.out.println(e.toString());


}
// Add CC Recipients.
Address ccList[] = new Address[1];
try {
ccList[0]= new Address("someemail@gmail.com", "some address");
} catch(AddressException e) {
System.out.println(e.toString());
}
try {
msg.addRecipients(Message.RecipientType.CC, ccList);
} catch (MessagingException e) {
System.out.println(e.toString());
}
// Add the subject.
msg.setSubject("A Test Email");
// Add the message body.
try {
msg.setContent("This is a test message.");
} catch(MessagingException e) {
// Handle messaging exceptions.
}
// Send the message.
try {
Transport.send(msg);
} catch(MessagingException e) {
System.out.println(e.getMessage());
}
System.out.println("Email sent successfully.");
Swati
  • 2,837
  • 7
  • 41
  • 85
jini
  • 10,563
  • 34
  • 95
  • 166

1 Answers1

1

Are you running this on a simulator? If so, which development environment (eclipse or JDE)? Have you started the MDS or are you using ESS? (With MDS 4, you don't need ESS.)

Personally, I use eclipse with the plug-in, then set the run-time configuration to launch MDS.

However, before doing that, you need to edit the rimpublic.property file to configure it to connect to your e-mail server (if you are using a remote e-mail server). If you are going to use a local mail client, configure MDS to use that as a pass-through.

Let me know what your setup / configuration is and I'll try to help more.

Jon
  • 188
  • 2
  • 12