Solved

Send e-mail with attachment using default email client

Posted on 2008-11-03
5
1,371 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 500 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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