views:

52

answers:

4

Well, for my program(s) I'd like to let the user send me an e-mail with any errors. Instead of relying on a forsaken SMTP server, I decided to let the user use his very own e-mail client to send an e-mail to a specified address.

So what I need is:
A sender (should not be changeable) (example: [email protected])
An attached file (should not be changeable) (example: "C:\a file.log")
(Optional) A body (changeable)

I hope it is possible!

+1  A: 

You can use the mailto command for this. See http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx for more information. Some mail clients support attachments on this. See the comments of the MSDN page for some information on this.

Pieter
Attachments are specifically what I need, and, from what I know, only Microsoft Office Outlook 2003 supports attachments. Edit: WinRar can send attachments...
Vercas
+1  A: 

The mailto protocol has limitations, such as not being able to specify an attachment (some mail clients support it, but it's not in the official protocol). Your best option is probably to use the MAPISendMail function to let MAPI do the hard work. See this article for details:

Sending files via the default e-mail client

I used this technique in the past, it seems to work perfectly.

Thomas Levesque
Forget the old comment, I have found a better way.
Vercas
+1  A: 

Hello!

Using mailto directly from you application cause potential problems. If you have specified mail account for receive e-mails you can be sure, that someone will use it somehow to sent you spam or thousands unwanted emails. In our company we struggled with this problem many times - at last, we decided to allow our customers to report problems in any other way - web page form. Now, when customer click 'report problem' this option displays a form for reporting bugs in default web browser. Opened link include some additional information which causing partial fill of the form opened by customer. Now, we have an intermediate layer and absolute control on server side who report problem (ip) and we can limit reporting for specified users. Next advantage of these solution is that you can forward emails to different departments depending on what form fields are marked/filled with.

UGEEN
Oops... I didn't think about spam... I first thought of using a web request to submit the data programatically and so to write it to a text/xml file in my server. But my problem is spaces and newlines...
Vercas
+1  A: 

Well, I have found the perfect solution!
For those who want to see it...
http://social.msdn.microsoft.com/Forums/en/netfxnetcom/thread/a75533eb-131b-4ff3-a3b2-b6df87c25cc8
http://www.eggheadcafe.com/community/aspnet/2/10019665/email-through-gmail-in-c.aspx

Vercas
I thought you didn't want to rely on a SMTP server ?
Thomas Levesque
Well I have found a free SMTP server that I can use. In the question, I meant I do not want to have my own.
Vercas