473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can I make SmtpMail.Send bring up Outlook email client?

How can I show the email client UI so the user can send the attachment
to the desired recipient. I get an exception if I leave the
MailMessage.To property blank. Is there any way to do this?

I found a Microsoft example that uses mapi32.dll that can do this. But
I can nopt make the SmtpMail work like I want.

Thanks in advance,

-Ed
Using System.Web.Mail;

MailMessage mailMsg = new System.Web.Mail.MailMessage();
mailMsg.To = "es*****@engius.com"; // Throws exception if left blank
mailMsg.From = "jo*****@engius.com";
mailMsg.Subject = "Hello";
mailMsg.Body = "My body";
mailMsg.Attachments.Add(new MailAttachment(fileAttachment));
SmtpMail.Send(mailMsg);
Nov 16 '05 #1
3 5032
From memory you might have to use the mailto syntax and start a process using the system.process namespace. I do not know if there has been a post here, but in the vbdotnet groups there have been several posts. Do a search for 'mailto' it should give you an answer.
"Ed Sutton" wrote:
How can I show the email client UI so the user can send the attachment
to the desired recipient. I get an exception if I leave the
MailMessage.To property blank. Is there any way to do this?

I found a Microsoft example that uses mapi32.dll that can do this. But
I can nopt make the SmtpMail work like I want.

Thanks in advance,

-Ed
Using System.Web.Mail;

MailMessage mailMsg = new System.Web.Mail.MailMessage();
mailMsg.To = "es*****@engius.com"; // Throws exception if left blank
mailMsg.From = "jo*****@engius.com";
mailMsg.Subject = "Hello";
mailMsg.Body = "My body";
mailMsg.Attachments.Add(new MailAttachment(fileAttachment));
SmtpMail.Send(mailMsg);

Nov 16 '05 #2
Found the Answer about 3 days ago in this group.

==================================================
This is the easy way :

using System.Diagnostics;

string toEmail = "de**@publicjoe.co.uk";
string subject = "Love the Program";
string body = "Thanks a lot";
string message = string.Format( "mailto:{0}?subject={1}&body={2}", toEmail,
subject, body );

Process.Start( message );

Add this to a linklabel and bobs your uncle.

Example app can be found at
http://www.publicjoe.f9.co.uk/csharp/snip/snip007.html
Hope this helps

Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html
VB Ebook at http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html

================================================== ==

"Glenn Wilson" wrote:
From memory you might have to use the mailto syntax and start a process using the system.process namespace. I do not know if there has been a post here, but in the vbdotnet groups there have been several posts. Do a search for 'mailto' it should give you an answer.
"Ed Sutton" wrote:
How can I show the email client UI so the user can send the attachment
to the desired recipient. I get an exception if I leave the
MailMessage.To property blank. Is there any way to do this?

I found a Microsoft example that uses mapi32.dll that can do this. But
I can nopt make the SmtpMail work like I want.

Thanks in advance,

-Ed
Using System.Web.Mail;

MailMessage mailMsg = new System.Web.Mail.MailMessage();
mailMsg.To = "es*****@engius.com"; // Throws exception if left blank
mailMsg.From = "jo*****@engius.com";
mailMsg.Subject = "Hello";
mailMsg.Body = "My body";
mailMsg.Attachments.Add(new MailAttachment(fileAttachment));
SmtpMail.Send(mailMsg);

Nov 16 '05 #3
Thank you for your reply.

I need to add multiple attachments as well. I do not see how I can do
this with this approach.

I guess I must stick with the "Simple MAPI" Microsoft example that uses
mapi32.dll. It works fine but takes a lot more code. I was hoping to
use the SmtpMail.Send built-in to System.Web.Mail but I can not get it
to launch the default email client.

Thank you for your suggestion,

-Ed

Glenn Wilson wrote:
Found the Answer about 3 days ago in this group.

==================================================
This is the easy way :

using System.Diagnostics;

string toEmail = "de**@publicjoe.co.uk";
string subject = "Love the Program";
string body = "Thanks a lot";
string message = string.Format( "mailto:{0}?subject={1}&body={2}", toEmail,
subject, body );

Process.Start( message );

Add this to a linklabel and bobs your uncle.

Example app can be found at
http://www.publicjoe.f9.co.uk/csharp/snip/snip007.html
Hope this helps

Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html
VB Ebook at http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html

================================================== ==

"Glenn Wilson" wrote:

From memory you might have to use the mailto syntax and start a process using the system.process namespace. I do not know if there has been a post here, but in the vbdotnet groups there have been several posts. Do a search for 'mailto' it should give you an answer.
"Ed Sutton" wrote:

How can I show the email client UI so the user can send the attachment
to the desired recipient. I get an exception if I leave the
MailMessage.To property blank. Is there any way to do this?

I found a Microsoft example that uses mapi32.dll that can do this. But
I can nopt make the SmtpMail work like I want.

Thanks in advance,

-Ed
Using System.Web.Mail;

MailMessage mailMsg = new System.Web.Mail.MailMessage();
mailMsg.To = "es*****@engius.com"; // Throws exception if left blank
mailMsg.From = "jo*****@engius.com";
mailMsg.Subject = "Hello";
mailMsg.Body = "My body";
mailMsg.Attachments.Add(new MailAttachment(fileAttachment));
SmtpMail.Send(mailMsg);

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: billg_sd | last post by:
My client app uses SmtpMail.Send() is failing on client PC's that are configured with Outlook 2003. I'm using code similar to: Dim Message As System.Web.Mail.MailMessage = New...
0
by: David Burson | last post by:
Hi, I have a VB.NET windows app that needs to automatically send a simple text email when my users run a new version of the app for the first time. I thought this would be simple, but after...
3
by: Jimmy | last post by:
I am trying to send an attachment using SmtpMail. I am able to send an Excel or text file, but when I try to send a pdf file, it throws an exception: could not access CDO.Message object. The file...
0
by: arkam | last post by:
Hi, I tryed to send an email with the smtpmail class in the .net framework and I got an error in Outlook. Here is my code: System.Web.Mail.MailMessage mail = new...
9
by: Kevin Spencer | last post by:
We just moved an ASP.Net app to a Windows 2003 Server, and the SMTPMail fails now with the following message: System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,...
0
by: Erwan | last post by:
I have a strange (but very blocking) result when using the smtpmail class from an ASPX page : here is the (very simple !) code... '-------------------------------------------------- mail.To =...
9
by: Russell Stevens | last post by:
I generate pdf files on my server and allow users to access them via a browser and also email them. Most files work fine whether the user uses his browser or gets an email with a pdf attachment...
0
by: Tony Castellano | last post by:
I'm using the smtpmail class (Framework 1.0) to send email via an outside server. The code used is pretty straightforward. I declare a MailMessage with a body, a to, from, and an attachment. ...
14
by: supz | last post by:
Hi, I use the standard code given below to send an email from an ASP.NET web form. The code executes fine but no Email is sent. All emails get queued in the Inetpub mail queue. I'm using my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.