How can I send an email from a Windows CE device (Compact Framework)?

2.3k Views Asked by At

I want to allow the user of the handheld device software I'm working on to send me email (the contents of a log file, which will have exception data and other info for debugging).

How can I do that? All the user should have to do, on seeing the contents of the log file (which I display to them on-demand in a form), is to mash a "send this" button. The contents of the log file (which can be read from the Textbox in which they are displaying) can be the body of the email message (rather than an attachment), with the subject line being something like "{user name} log contents"

If I have to prompt the user for their email address, that's probably okay, but I would prefer to use one of our email addresses as the sender, so that it's seen as being both from us and to us (probably two different accounts, though).

1

There are 1 best solutions below

0
On BEST ANSWER

One way would to use the SDF and the OpenNETCF.Net.Mail namespace objects. It works like the System.Net.Mail objects, so sending an email would look something like this:

var message = new MailMessage();

message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));
message.Subject = "Hello World";
message.Body = "This is my message body";

var client = new SmtpClient();

client.Host = "smtp.myserver.com";
client.Credentials = new SmtpCredential("myusername", "mypassword", "mydomain");

client.Send(message);