Solved

Send e-mail with attachment using default email client

Posted on 2008-11-03
5
1,362 Views
Last Modified: 2010-04-21
Hi Experts,
In my application (winform application) an Excel file is created. I then want to open the default email client on the local machine with the Excel file attached to it and let the user enter the additional details (recipients, etc).

The email client will be MS Outlook or Lotus Notes 8.

I have tried:
- Mailto, but this does not seem to be a very stable solution.
- Smtp, but I am not able to open the email client before sending
- MAPI, but I am not able to make VB recognize any MAPI names (not sure if I need to install or import namespaces)

I hope someone can give me some advice.
Best regards, MB

0
Comment
Question by:mark_norge
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:ladarling
Comment Utility
You need to import:
Imports System.Web.Mail

There is a full source example of creating a MailMessage object here:
http://www.freevbcode.com/ShowCode.asp?ID=5486

 
0
 
LVL 11

Expert Comment

by:ladarling
Comment Utility
I then want to open the default email client on the local machine with the Excel file attached to it and let the user enter the additional details (recipients, etc).
Unless you wanted to use mailto: or buy something like Rebex:
http://www.rebex.net/mail.net/purchase.aspx
Then it would probably be easier to just create your own mail message editor in VB. Of course, you dont automatically get the access to the Global Address List or contacts like you would in those programs, but there is plenty of examples of accessing those from VB.NET.
 
0
 

Author Comment

by:mark_norge
Comment Utility
Thanks for the reply ladarling,

Based on your reply and information on the web I see that "MailMessage" in itself is not able to show the e-mail "as draft" in the default local email client before sending. Since it is possible to get the contacts, I can create a form and by this get the required functionality. Even if I would like to use the default local email client to do most of this, this is ok.

One thing then remains unclear to me. What are the requirements on the local machine? Is it possible to use this method regardless of the installed email client (Outlook, Lotus Notes?). What are the requirements on the local machine?

Regards, MB

 
0
 
LVL 11

Accepted Solution

by:
ladarling earned 500 total points
Comment Utility
One thing then remains unclear to me. What are the requirements on the local machine? Is it possible to use this method regardless of the installed email client (Outlook, Lotus Notes?). What are the requirements on the local machine?
Yes, you can use this method so long as your application has access to an SMTP server, regardless of the client software. You will, of course, have to specify the mail server name and port (usually 25).
I should point out that Microsoft want developers to migrate to the System.Net.Mail namespace, which is very similar to System.Web.Mail's functionality, plus some enhancements.
So , the 'updated' method would use a System.Net.Mail.MailMessage and a System.Net.Mail.SmtpClient, the members of which are:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient_members.aspx
 
0
 

Author Closing Comment

by:mark_norge
Comment Utility
Thanks a lot, excellent help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now