如何使用Android Gmail Guard发送多封邮件

时间:2015-01-28 17:23:47

标签: android email

我正在尝试使用Android上的GmailSender类发送多封电子邮件,我在sender.SendEmail构建器中添加了3个邮件联系人。我尝试使用下面的这个实现发送,但没有用。

    private Boolean NotifyWithMail(String localFile)
    {
        Boolean ret = false;

        final GMailSender sender = new GMailSender("mymail@gmail.com", "******");

        try
        {
            ArrayList<Contato> colecao = new ConfigurationPreferences().
            if(colecao.size() < 1) return false;
            else
            {
                sender.addAttachment(localFile,"");//Anexo
                sender.sendMail("Alerta", "Movimento identificado no ambiente monitorado", 
                        "mymail@gmail.com",
                        colecao.get(0).getEmail().toString() + "; "
                                + colecao.get(1).getEmail().toString() + "; "
                                + colecao.get(2).getEmail().toString());

                ret = true;
            }
        }
        catch (Exception e)
        {
            ret = false;
            Log.e("SendMail", e.getMessage(), e);
        }

        return ret;
    }

1 个答案:

答案 0 :(得分:0)

进行测试,我将替换&#34 ;;&#34; by&#34;,&#34;分隔每个电子邮件地址并且有效。

最终代码

sender.sendMail("Alerta", "Movimento identificado no ambiente monitorado", 
                        "mymail@gmail.com",                             
                        colecao.get(0).getEmail().toString() + ", "
                                + colecao.get(1).getEmail().toString() + ", "
                                + colecao.get(2).getEmail().toString());