Moving on from my original question below:
Android Sending an email using a list of email addresses
I have tried to populate the email address line by using a string. When writing the email the message section is populated with the answer given by clicking on a spinner, the code for this is shown as “%1$s”. So if I have a spinner that has 4 different countries in the string for the main email I put:
Country: %1$s
And it will show in the final email to be sent as:
Country: UK
For example.
When I put this string into the email Address instead of it originally looking like:
home%1$s@gmail.com
And coming out in the final email as:
It stays as home%1$s@gmail.com!
Is there a reason for this? Is it something that cannot be added to the address line?
I have attached my code below and would very much appreciate someones help. I have been pulling my hair out with this one. The rest of the app is complete!
Main Activity
public void sendFeedbackMessage(String subject, String message) {
Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { getResources().getString(R.string.emailaddress_format) };
String bEmailList[] = { ("country@gmail.com") };
messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
messageIntent.putExtra(Intent.EXTRA_CC, bEmailList);
//email.putExtra(Intent.EXTRA_BCC, new String[]{to});
messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
messageIntent.setType("plain/text");
messageIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
startActivity(messageIntent);
}
}
And the relevant String
<string
name="emailaddress_format">country%1$s@gmail.com</string>
If any more code is needed to see what I am trying to do then please let me know and I will add it. I didnt want to overload everyone with the whole code and then try and explain where I am struggling.
Hopefully someone can help me and i’m making sense.
Many Thanks
Not sure on the exact answer to the particular problem you’re having, but an easier way to accomplish what it seems like you’re trying to accomplish would be:
This will get the country the person has selected from the spinner and convert it to a String, which you can then place in the
EXTRA_EMAILas you’re doing already.