Sometimes, while writing a WPF or WinForms GUI application, you might need to allow the user to send a pre-populated e-mail from her machine. A typical example would be sending an e-mail to your technical support from the application. A naive approach to implement this functionality is to use the following code sniplet:

System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("mailto:a@b.com?subject=test&body=xxxxx"));

However this has its limitations. The size of the string you can pass to the ProcessStartInfo's constructor is limited, therefore if your data doesn't fit into it, it will be truncated - not very convenient, if you are trying to pass in a long exception stack. You will also have to url-encode the data, which adds to the length of the constructed string and complicates your code.

An alternative solution would be to use MAPI (Mail API) via COM+ Interop. MAPI allows you to invoke the default mail client, set large body messages and even add attachments, which is impossible with the ProcesStartInfo altogether. While you can write the code yourself, some kind soul has already done it for you. More information can be found here .

Tags: None
Categories: None |

0 comments have been posted.

Your email: we will send you a confirmation link to this address to confirm your identity and to prevent robot posting
Get in touch
»...«
Follow updates

Join our social networks and RSS feed to keep up to date with latest news and publications