Reputation: 89
I have to develop one android send mail use javamailapi application.
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("[email protected],[email protected]"));
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="[email protected]"
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("Email,[email protected]"));
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 ????
Upvotes: 0
Views: 1481
Reputation: 28823
I think you need to replace
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("Email,[email protected]"));
with
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(Email+",[email protected]"));
Email address was not found because it was trying to find "Email" instead of value of Email("[email protected]").
Hope that helps,
Upvotes: 1