6

In 2008 Jeff wrote a post on crashing responsibly. In that spirit, I'm trying to add a "send bug report" button to my crash error dialog. The idea is that the user can easily send a full bug report which already includes version information, OS info, stack trace... This information should be put in the message body or in attachment files.

Unfortunately, sending such an email from a .NET application appears to be non-trivial:

  • System.Net.Mail is not what I am looking for: I can't be sure that a connection to an SMTP server can be made in all environments, and I don't want to put the burden of configuring the local SMTP hostname and port on my users. Instead, I just want to launch the existing email software on the system with a precomposed message.
  • Using the OS to open a "mailto:" URL works, but there are annoying restrictions to the amount of data that can be passed this way. Also, it appears that attachments are not really supported by the mailto spec.
  • mapi.dll would probably do what I want as illustrated by this codeproject article, but I read elsewhere that mapi.dll is fundamentally incompatible with .NET causing random crashes.

Has anyone out there found a safe and reliable solution to do this?

Community
  • 1
  • 1
Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
  • (I have edited the title after the answers made me realize that the solution doesn't have to involve email.) – Wim Coenen Dec 21 '10 at 14:46

3 Answers3

3

We have solved this by creating a simple WCF web service that takes the stack trace, zipped logs etc, which the client posts to it and then let the web service server send the email. This way you don't have to have the SMTP authentication information on the client side, nor do you have to rely on the user to submit the error report via their email client.

We're now even zipping and submitting client side logs periodically to the backend server via this webservice and analyze those logs to preemptively detect any client side issues before they become problematic to the client

TJF
  • 2,248
  • 4
  • 28
  • 43
  • +1 interesting. I do worry that our software tends to run in locked-down environments where random outgoing connections are not always allowed. On the other hand, I also can't be sure that sending email is possible, so I need a fall-back solution anyway (e.g. "save error report to file"). – Wim Coenen Dec 21 '10 at 14:22
  • you could simply wrap the service call in a try/catch and if it fails, you give the user the option to send it via their email client – TJF Dec 21 '10 at 14:53
2

A quick way would be to set up your server to receive the information via PHP f.e. . Create an ErrorReport.php and try to call it with every information you have wrapped in a base64 package.

This 'only' needs Internet-Access on Port 80, which is most likely available. From there you can process the information and pass it on into a database f.e. .

Bobby
  • 11,419
  • 5
  • 44
  • 69
0

You could - when using your own compatible server - just create a "telnet" like socket structure to post the data directly into your server.

Something like this: http://www.csharphelp.com/2007/07/sending-email-with-c-using-smtp/

riffnl
  • 3,248
  • 1
  • 19
  • 32