收件人正在接收电子邮件,但没有附件。这是代码,任何专家都知道我哪里出错了?
Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "mymailgmail.com" };
messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
...
messageIntent.setType("image/jpeg");
File downloadedPic = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "MyApp.jpg");
messageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
startActivity(Intent.createChooser(messageIntent, getResources().getString(R.string.chooser_pic)));
我明白了:
file://附件路径必须指向file:// sdcard。忽略附件文件://...file名称为MyApp.jpg
我没有收到图片,只是在短信之上。感谢。
答案 0 :(得分:40)
尝试以下代码......
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
答案 1 :(得分:9)
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailaddress);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.setType("application/image");
Uri uri = Uri.parse("file://" + filepath);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(emailIntent);
答案 2 :(得分:0)
// Put the Ajax call in a function
let deleteRecord = function(itemId){
$.ajax({
type: "POST",
url: '@Url.Action("DeleteRecord")',
data: {id: itemId},
success: function (data) {
if (!data) {
doPopStatus("ERROR", "Something went haywire in the submit. Try Again.", "modal-header alert-danger", "fa fa-exclamation-circle text-danger", "alert", "text-danger");
} else if (data.success === true) {
doPopStatus("Success!", "The record has been removed.", "modal-header alert-success", "fa fa-check-circle text-success", "alert", "text-primary", '@Url.Action("Index")');
} else {
//if (data.isSuccessful === false) {
doPopStatus("Delete Failed!", data.status, "modal-header alert-danger", "fa fa-exclamation-triangle text-warning", "alert", "text-danger");
}
},
error: function (jqXHR, textStatus, errorThrown) {
goReady();
console.error(jqXHR);
let errorDetails = doParseResponseErrorDetails(jqXHR);
doPopStatus("ERROR", "Something went haywire in the post. Try Again.<p>" + jqXHR.status + ": " + jqXHR.statusText + "<br />" + '<div class="bs-callout bs-callout-danger">' + errorDetails + "</div></p>", "modal-header alert-danger", "fa fa-exclamation-circle text-danger", "alert", "text-danger");
}
});
}