EmailComposeTask in WP7

Apr 30, 2011 at 12:23 AM

This seems like it should be an easy one to figure out, but ... How do you supply values for the To address and Subject when using the <code>TaskLaunchRequested()</code> method to launch an e-mail?

I have the launcher installed in my bootstrapper, and right now my viewmodel code looks like this:

public void LaunchEmailTask()
{
       TaskLaunchRequested(this, TaskLaunchEventArgs.For<EmailComposeTask>());
}

It pulls up an e-mail, but I want to include my contact info so users can submit bugs.

Suggestions?

Coordinator
May 2, 2011 at 2:04 PM

If you implement IConfigure<TTask> on your VM, you will get a callback with the task so that you can configure it. I'm working on a new launcher/chooser strategy now. It's not available yet, but keep an eye on the trunk in the next few weeks.

May 3, 2011 at 12:38 AM

Thanks, Rob. I see the interface went ahead and implemented it:

public void ConfigureTask(EmailComposeTask task)
        {
            task.To = "myemail@domain.com";
            task.Subject = "App Feedback";
        }


I'm still a little fuzzy on how to call this, since it wants an EmailComposeTask as a parameter. I tried everything I could think of but couldn't quite get it. Could you give me a hint?

Coordinator
May 3, 2011 at 11:35 AM

It's all a bit weird, I admit. But when you raise the event, if you implement that interface, you will get called back with a pre-created instance of the task which you can configure. You never actually have to create the task yourself.

May 3, 2011 at 12:10 PM

Gotcha. It's a little unexpected, but it's better than having to manually create the task. Looking forward to seeing what your new strategy is around this scenario. Thanks for the help!

Coordinator
May 3, 2011 at 7:19 PM

Take a look in the trunk.