Solved

Send e-mail with attachment using default email client

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate Unique ID in VB.NET 21 128
VB.net Open video relating to control 2 38
VB.net Code to make a TaskPane float in Excel Add-in 2 34
FTP recursive download files 5 24
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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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