wtf nth

  • Archive
  • RSS

Windows Phone 7: Allowing the user to send an email from your app

Senthil Kumar mentions a way to work the EmailComposeTask in Windows Phone 7 programming, but the code can be even more concise than what he lists. He writes:

private void button1_Click(object sender, RoutedEventArgs e)
{
    EmailComposeTask emailcomposer = new EmailComposeTask();
    emailcomposer.To = "<a href="mailto:test@ginktage.com">test@ginktage.com</a>";
    emailcomposer.Subject = "subject from test app";
    emailcomposer.Body = "This is a test mail from Email Composer";
    emailcomposer.Show();
}

But thanks to the miracle of C#’s object initializer syntax, it can be a bit cleaner:

private void AppBarShare_Click(object sender, EventArgs e)
{
    new EmailComposeTask {To = myAddr, Subject = myTitle, Body = myBody}.Show();
}

Also, he includes HTML in his test strings, which the EmailComposeTask doesn’t actually support. (It won’t render the HTML.)

  • 9 months ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

About

stuff I learned the hard way

Pages

  • why
  • me
  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr