if(field == Attach)
{
try
{
fconn = (FileConnection) Connector.open("res/images.jpg", Connector.READ_WRITE);
if(fconn.exists())
{
inputStream=fconn.openInputStream();
byte[] data = IOUtilities.streamToBytes(inputStream);
inputStream.close();
fconn.close();
multipart = new Multipart();
SupportedAttachmentPart attach = new SupportedAttachmentPart(multipart, ".txt/.jpg", "images.jpg", data);
multipart.addBodyPart(attach);
Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);
Message message = new Message(folders[0]);
try
{
Address toAdd = new Address("lib_aman@yahoo.com","Aman");
Address toAdds[] = new Address[1];
toAdds[0] = toAdd;
message.addRecipients(Message.RecipientType.TO,toAdds);
message.setContent(multipart);Transport.send(message);
Dialog.inform("Email sent : " +toAdd);
}
catch (Exception e)
{
Dialog.inform(e.toString());
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
I am trying This code but it still not working, so kindly help me out for this.