如何为 android Gmail API 设置抄送和发件人姓名?

How to set CC and sender name for android Gmail API?

来自Google官网,这是一种在发送前创建邮件的方法。

public static MimeMessage createEmail(String to,
                                              String from,
                                              String subject,
                                              String bodyText)
                throws MessagingException {
            Properties props = new Properties();
            Session session = Session.getDefaultInstance(props, null);

            MimeMessage email = new MimeMessage(session);

            email.setFrom(new InternetAddress(from));
            email.addRecipient(javax.mail.Message.RecipientType.TO,
                    new InternetAddress(to));
            email.setSubject(subject);
            email.setText(bodyText);
            return email;
        }

我找不到可以为抄送电子邮件地址和发件人姓名设置的 API。 我在互联网上搜索,也找不到答案。请对此提供帮助。

使用 setter 方法设置收件人

  message.addRecipient(RecipientType.BCC, new InternetAddress(to));
    message.addRecipient(RecipientType.CC, new InternetAddress(to));

你可以试试下面的方法

 message.addRecipient(RecipientType.BCC, new InternetAddress(
        "your@email.com"));
 message.addRecipient(RecipientType.CC, new InternetAddress(
        "yourOther@email.com"));

归功于him