电子邮件分享使用 android intent Text Only
这将触发本机电子邮件客户端以共享文本。
参数 :电子邮件地址,主题,正文。
代码示例:
你可以在任何需要的地方调用该函数 *(主要是在单击侦听器中),*如下所示
调用功能
shareEmail("sample@gmail.com", "Email sharing example", "This the sample demo to share the sample text through native email clients using Android Intent");
全局功能
public void shareEmail(String to_email_id, String subject, String body) {
// This function will open the email client installed in the device to share from your own app through intent.
Intent sharingIntent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
sharingIntent.setType("message/rfc822");
/* All the below fields are optional. If not given simply opens the email client */
// To email id
sharingIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{to_email_id});
// Subject that needs to appear while sharing
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
// Body of the mail content shared.
sharingIntent.putExtra(Intent.EXTRA_TEXT, body);
(mContext).startActivity(Intent.createChooser(sharingIntent, "Share content through email")
);
} // shareEmail