I have to develop one android send mail use javamailapi application.
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("mercy.krishnaveni@gmail.com,demo@mercuryminds.com"));
Using the above code mail is send to the recipient But Now I wanted to send mail whose Id is written in the following String.
string Email="mercy.krishnaveni@gmail.com"
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("Email,demo@mercuryminds.com"));
When I use the above code mail is not getting send properly and it is giving me following error:
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
please help me to solve my error and also how can i send the email ????
I think you need to replace
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("Email,demo@mercuryminds.com"));
with
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(Email+",demo@mercuryminds.com"));
Email address was not found because it was trying to find "Email" instead of value of Email("mercy.krishnaveni@gmail.com").
Hope that helps,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.