How to open a new email, and assign subject, using .NET Compact Framework
Asked Answered
B

2

7

Basically I'm trying to accomplish the same thing that "mailto:[email protected]" does in Internet Explorer Mobile.

But I want to be able to do it from a managed Windows Mobile application. I don't want to send an email pro grammatically in the background.

I want to be able to create the email in Pocket Outlook and then let the user do the rest.

Hopefully that helps you hopefully help me!

Bellerophon answered 6/10, 2008 at 13:14 Comment(0)
P
8

I assume you use C#. You add a reference to System.Diagnostics and then write the following code:

ProcessStartInfo psi = 
  new ProcessStartInfo("mailto:[email protected]?subject=MySubject", "");
Process.Start(psi);

This will start the default email client on your mobile device.

The mailto protocol definition might come handy too.

Pollak answered 6/10, 2008 at 13:36 Comment(1)
Thanks Petros! Great answer, worked perfectly and was clean and simple, which is something I really wanted and needed. You really helped me out.Bellerophon
C
3

You can also use Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.DisplayComposeForm like so:

OutlookSession sess = new OutlookSession();
EmailAccountCollection accounts = sess.EmailAccounts;
//Contains all accounts on the device  
//I'll just choose the first one -- you might want to ask them
MessagingApplication.DisplayComposeForm(accounts[0], 
    "[email protected]", "The Subject", "The Body");

The DisplayComposeForm method has a lot of overloads with options for attachments and more.

Conto answered 19/11, 2008 at 14:44 Comment(1)
Thanks, Jake, that's exactly what i've been looking for.Devland

© 2022 - 2024 — McMap. All rights reserved.