?
Solved

Send e-mail with attachment using default email client

Posted on 2008-11-03
5
Medium Priority
?
1,373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:ladarling
ID: 22867549
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
ID: 22868344
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
ID: 22870373
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 2000 total points
ID: 22871189
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
ID: 31512696
Thanks a lot, excellent help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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