Android 向多个地址发送电子邮件
我想选择一些电子邮件地址,然后向所有这些地址发送电子邮件 我的代码如下:Android 向多个地址发送电子邮件,android,email-address,Android,Email Address,我想选择一些电子邮件地址,然后向所有这些地址发送电子邮件 我的代码如下: emailIntent .putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{listofemailaddresses}); emailIntent .putExtra(android.content.Intent.EXTRA_SUBJECT, "My Subject"); emailIntent .putExtra(android.content.Intent
emailIntent .putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{listofemailaddresses});
emailIntent .putExtra(android.content.Intent.EXTRA_SUBJECT, "My Subject");
emailIntent .putExtra(android.content.Intent.EXTRA_TEXT, Constants.SMS_MESSAGE);
this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));`
ListoFeailAddresses
是一个字符串,其中包含所有电子邮件,并用“,”符号分隔。但是,在此字段中,To字段始终为空 将此行添加到代码中:
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "appsupport@YOUR_DOMAIN.com" });
这将填充屏幕的“收件人”部分。如果您的电子邮件地址列表由
分隔,
则拆分该字符串以获得单个电子邮件id,如下所示:Intent intent = null;
intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL,new String[] { "abc@gmail.com" , "test@gmail.com", "xyz@test.com"});
startActivity(intent);
String[]emailList=emailAddresses.split(“,”)代码>
现在将emailList与您的意图一起使用。额外的\u EMAIL
键,因为这将显示发送电子邮件表单字段中的所有电子邮件地址
这个代码怎么样:
final Intent emailLauncher = new Intent(Intent.ACTION_SEND_MULTIPLE);
emailLauncher.setType("message/rfc822");
emailLauncher.putExtra(Intent.EXTRA_EMAIL, emailList);
emailLauncher.putExtra(Intent.EXTRA_SUBJECT, "check this subject line");
emailLauncher.putExtra(Intent.EXTRA_TEXT, "hey check this message body!");
try{
startActivity(emailLauncher);
}catch(ActivityNotFoundException e){
}
谢谢我让它工作xD。你能告诉我如何发送短信到多个号码吗?