We help IT Professionals succeed at work.

How can I open a new email window with attachment in VB .net

Rabbit80
Rabbit80 asked
on
My application downloads a file via webservices and saves it to a temporary location.

How can I now attach that file to a new email so that the user can enter an email address, message body, subject etc? The email client could be Outlook (2000 / 2003 / 2007 / 2010) or Outlook Express.

I have tried using MAPI without success - the email client does not open or when sending brings up a warning (in Outlook 2007 at least). I have also tried Mailto: however the attachment is not added.

The only way I can think of is to replicate the Mail Recipient in the Send To folder (or any other file with a MAPIMAIL extension) - how can I simulate the file drop onto this Icon in VB.net? (Using the clipboard is one way, but I need to ensure the existing clipboard contents are not wiped!)
Comment
Watch Question

Full stack Software Engineer
Commented:
grab the code from here: http://www.codeproject.com/KB/IP/SendFileToNET.aspx
it's working perfectly, the only thing missing is that you need to add [STAThread] on your Main method in your application

Author

Commented:
Spot on. Thank you.