0

我必须开发一个使用 javamailapi 的 android 发送邮件应用程序。

message.setRecipients(Message.RecipientType.TO,
                        InternetAddress.parse("mercy.krishnaveni@gmail.com,demo@mercuryminds.com"));

使用上面的代码邮件发送给收件人但现在我想发送 Id 写在以下字符串中的邮件。

 string Email="mercy.krishnaveni@gmail.com"
 message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("Email,demo@mercuryminds.com"));

当我使用上面的代码时,邮件没有正确发送,它给了我以下错误:

01-22 07:13:31.609: E/AndroidRuntime(959): FATAL EXCEPTION: main
01-22 07:13:31.609: E/AndroidRuntime(959): java.lang.RuntimeException: javax.mail.SendFailedException: Invalid Addresses;
01-22 07:13:31.609: E/AndroidRuntime(959):   nested exception is:
01-22 07:13:31.609: E/AndroidRuntime(959):  com.sun.mail.smtp.SMTPAddressFailedException: 553-5.1.2 We weren't able to find the recipient domain. Please check for any
01-22 07:13:31.609: E/AndroidRuntime(959): 553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods,
01-22 07:13:31.609: E/AndroidRuntime(959): 553 5.1.2 or other punctuation after the recipient's email address. ni8sm10202402pbc.70

请帮我解决我的错误,我该如何发送电子邮件????

4

1 回答 1

1

我认为你需要更换

message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("Email,demo@mercuryminds.com"));

message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(Email+",demo@mercuryminds.com"));

未找到电子邮件地址,因为它试图查找“电子邮件”而不是电子邮件的值(“mercy.krishnaveni@gmail.com”)。

希望有帮助,

于 2013-01-22T09:20:28.590 回答