开发者

Sending e-mail from Android not working

I just can't seem to get the e-mail sending working in Android. Probably something stupid but I can't find it:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/plain")
               .putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "jb@mail.anykey.co.il" })
               .putExtra(android.content.Intent.EXTRA_SUBJECT,"Exception in Yaniv!")
               .putExtra(android.content.Intent.EXTRA_TEXT,"test");
    ApplicationControllerB开发者_开发技巧ase.getMyApplicationContext().startActivity(Intent.createChooser(emailIntent,
             "Send mail...").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

I am not getting any error or exception on the startActivity command.

=======

Edit:

Seems that this is the same problem as this guy is having: Android: How to start an activity from an UncaughtExceptionHandler set in application


setType should be plain/text

try with the following code

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("plain/text");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"webmaster@website.com"});
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "mySubject");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "myBodyText");
    startActivity(Intent.createChooser(emailIntent, "Send mail..."));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜