[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Send e-mail with attachment using default email client

Posted on 2008-11-03
5
Medium Priority
?
1,375 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
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 21 hours left to enroll

834 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