<p>I'm working on a Windows Forms (.NET 3.5) application that has a built-in exception handler to catch any (heaven forbid) exceptions that may arise. I'd like the exception handler to be able to prompt the user to click a <kbd>Send Error Report</kbd> button, which would then cause the app to send an email to my FogBugz email address.</p>

<p>What's the best way to do this, and are there any "gotchas" to watch out for?</p>

[{'answer_id': 57935, 'author': 'Esteban Araya', 'author_id': 781, 'author_profile': 'https://Stackoverflow.com/users/781', 'pm_score': 3, 'selected': True, 'text': '<p>You\'ll want to use the SmtpClient class as outlined <strong><a href="http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx" rel="nofollow noreferrer">here</a></strong>.<br>\nThere are no gotchas - sending email is about as easy as it gets.</p>\n'}, {'answer_id': 57949, 'author': 'Eric Z Beard', 'author_id': 1219, 'author_profile': 'https://Stackoverflow.com/users/1219', 'pm_score': 1, 'selected': False, 'text': '<p>You might also want to check out the 3rd party <a href="http://www.aspnetemail.com/" rel="nofollow noreferrer">aspNetEmail</a> library, which has a lot of useful features to offer above what System.Net.Mail gives you.</p>\n'}, {'answer_id': 57950, 'author': 'Brannon', 'author_id': 5745, 'author_profile': 'https://Stackoverflow.com/users/5745', 'pm_score': 2, 'selected': False, 'text': "<p><em>In a controlled environment,</em> using SmtpClient would be the answer.  But on a user's machine you would need an SMTP server to send through.</p>\n\n<p>You could prompt the user for their SMTP credentials, but I think that would be impractical for your case.  As a user, I would not want to provide my SMTP credentials to a random app (think SPAM).  You also don't want to hard-code your own SMTP credentials into the app, it would be trivial for a malicious user to sniff those credentials and use your server to send SPAM.</p>\n\n<p>Ideally you would be able to use the user's mail agent to send the email.  I was thinking you might be able to formulate and execute a mailto: URL, but I'm not sure if you'd be able to specify the body or any attachments for the message.</p>\n"}, {'answer_id': 58023, 'author': 'Dr8k', 'author_id': 6014, 'author_profile': 'https://Stackoverflow.com/users/6014', 'pm_score': 3, 'selected': False, 'text': '<p>You shouldn\'t need to worry about client credentials and just use the SmtpClient as suggested by Esteban. You will need the user to provide a valid Smtp server url at configuration, but most ISPs allow anonymous smtp providing you are on their network (one of their clients) - as long as the user puts in the url for their ISPs smptp server then most people wouldn\'t have any problems.</p>\n\n<p>Note: There is a predefined section of the .config file for storing the configuration options for the SmtpClient object. If you put the settings in there you don\'t have to explicitly set anything in you code when sending an email. An example of the section is below:</p>\n\n<pre><code>&lt;system.net&gt;\n   &lt;mailSettings&gt;\n      &lt;smtp deliveryMethod="Network" from="stuff@somewhere.com.au"&gt;\n         &lt;network host="smtp.somewhere.com.au" /&gt;\n      &lt;/smtp&gt;\n   &lt;/mailSettings&gt;\n&lt;/system.net&gt;\n</code></pre>\n\n<p>The user name and password are optional. Intellisense works for these parts of the config file.</p>\n\n<p>Edit: slight correction to my code example.</p>\n'}, {'answer_id': 58093, 'author': 'Byron Ross', 'author_id': 1811110, 'author_profile': 'https://Stackoverflow.com/users/1811110', 'pm_score': 2, 'selected': False, 'text': '<p>You mentioned you\'re using Fogbugz.</p>\n\n<p>Try <a href="http://www.fogcreek.com/FogBugz/blog/post/C-wrapper-for-the-FogBugz-API.aspx?isl=59722" rel="nofollow noreferrer">http://www.fogcreek.com/FogBugz/docs/60/topics/customers/BugzScout.html?isl=59722</a>\nor <a href="http://www.fogcreek.com/FogBugz/blog/post/C-wrapper-for-the-FogBugz-API.aspx?isl=59722" rel="nofollow noreferrer">http://www.fogcreek.com/FogBugz/blog/post/C-wrapper-for-the-FogBugz-API.aspx?isl=59722</a></p>\n\n<p>There is some sample code around, I think in your FB install directory.\nI checked with Michael Pryor re: licensing and he said it was fine to use their code, but YMMV, so I\'d check.</p>\n\n<p>It provides a good starting point. </p>\n'}, {'answer_id': 91522, 'author': 'Robbo', 'author_id': 2418, 'author_profile': 'https://Stackoverflow.com/users/2418', 'pm_score': 0, 'selected': False, 'text': '<blockquote>\n  <p>You\'ll want to use the SmtpClient class as outlined <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx" rel="nofollow noreferrer">here</a>.\n  There are no gotchas - sending email is about as easy as it gets.</p>\n</blockquote>\n\n<p>An extensive <a href="http://www.systemnetmail.com/default.aspx" rel="nofollow noreferrer" title="System.Net.Mail FAQ">System.Net.Mail FAQ</a> is located <a href="http://www.systemnetmail.com/default.aspx" rel="nofollow noreferrer" title="System.Net.Mail FAQ">here</a>.</p>\n'}]
['https://Stackoverflow.com/questions/57919', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5473/']