0

I am sending emails from my application. I want to know if there is a way to define templates for eg :

subject: Regarding {{title}} 
Body: You may be interested in the product {{title}} \b {{desc}} 

I would like to define this templates in some resource file.

Thanks for your help and time.

Barmaley
  • 16,638
  • 18
  • 73
  • 146
png
  • 4,368
  • 7
  • 69
  • 118

2 Answers2

1

Just construct mailto URL in accordance with RFC-2368, which includes subject and other fields. So in the end you'll have URI which can be used to start email sender activity:

Uri uri=Uri.parse("mailto:example@example.com?subject=Here goes test message");
intent = new Intent(Intent.ACTION_SENDTO, uri);
activity.startActivity(intent);

Futhero you can programmatically construct mailto URL as you want

Barmaley
  • 16,638
  • 18
  • 73
  • 146
0

You can put in strings.xml w/ string format character like %d %s %f..., and make use of String.format().

It's nice if others have better ideas :)

Pete Houston
  • 14,931
  • 6
  • 47
  • 60
  • Formatting strings If you need to format your strings using String.format(String, Object...), then you can do so by putting your format arguments in the string resource. For example, with the following resource: Hello, %1$s! You have %2$d new messages. In this example, the format string has two arguments: %1$s is a string and %2$d is a decimal number. You can format the string with arguments from your application like this: Resources res = getResources(); String text = String.format(res.getString(R.string.welcome_messages), username, mailCount); – png Oct 08 '11 at 07:21
  • i got this answer from http://stackoverflow.com/questions/3656371/dynamic-string-using-string-xml – png Oct 08 '11 at 07:22