我可以通过此代码发送电子邮件,并且电子邮件已成功发送 但问题是我想将图片附加到我的电子邮箱中。
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("myemailaddress@gmail.com"));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(reciep));
message.setSubject(subjct);
message.setContent(txtmsg,"text/html; charset=utf-8");
Transport.send(message);
下面是我可以拍照并将其保存在myfolder中的方法。
private void saveImage(byte[] arg0) {
String root = Environment.getExternalStorageDirectory() + "/.MeraFolder";
File myDir = new File(root);
myDir.mkdirs();
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String fname = timeStamp + ".jpg";
file = new File(myDir, fname);
if (file.exists()) {
file.delete();
}
Bitmap bitmap1 = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);
FileOutputStream out;
try {
out = new FileOutputStream(file);
bitmap1.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
现在我有两个问题
任何帮助将不胜感激,因为我是android的新手