通过默认电子邮件应用程序在Android上发送邮件 [英] Sending email on android via default email application

查看:129
本文介绍了通过默认电子邮件应用程序在Android上发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可以发送电子邮件的android应用程序。以下代码可让我从Android设备上的默认Gmail应用发送电子邮件。我想知道我应该设置什么类,以便我可以从默认的android邮件应用程序发送电子邮件?

  Intent sendIntent = new Intent (Intent.ACTION_VIEW); 
sendIntent.setClassName(com.google.android.gm,com.google.android.gm.ComposeActivityGmail);
sendIntent.putExtra(Intent.EXTRA_EMAIL,new String [] {abc@gmail.com});
sendIntent.setData(Uri.parse(abc@gmail.com));
sendIntent.putExtra(Intent.EXTRA_SUBJECT,enter subject);
sendIntent.setType(plain / text);
sendIntent.putExtra(Intent.EXTRA_TEXT,插入文本);
startActivity(sendIntent);


解决方案

你不必。我正在使用以下方式发送带有默认邮件服务的电子邮件。

  Uri uri = Uri.parse(mailto:info @ yourcompany .COM); 
Intent myActivity2 = new Intent(Intent.ACTION_SENDTO,uri);
myActivity2.putExtra(Intent.EXTRA_SUBJECT,
客户评论/问题);
startActivity(myActivity2);


I am developing an android application that can send email. This following code lets me send email from my default gmail app on android device. I was wondering what the classes i should set so that i can send email from default android mail application?

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "abc@gmail.com" });
sendIntent.setData(Uri.parse("abc@gmail.com"));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "enter subject");
sendIntent.setType("plain/text"); 
sendIntent.putExtra(Intent.EXTRA_TEXT, "Insert text");
startActivity(sendIntent);

解决方案

You don't have to. I am using following to send an email with default mail service.

        Uri uri = Uri.parse("mailto:info@yourcompany.com");
        Intent myActivity2 = new Intent(Intent.ACTION_SENDTO, uri);                                   
                    myActivity2.putExtra(Intent.EXTRA_SUBJECT,
                "Customer comments/questions");
        startActivity(myActivity2);

这篇关于通过默认电子邮件应用程序在Android上发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆