469,602 Members | 1,845 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

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 4898
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by billg_sd | last post: by
reply views Thread by David Burson | last post: by
3 posts views Thread by Jimmy | last post: by
9 posts views Thread by Kevin Spencer | last post: by
9 posts views Thread by Russell Stevens | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.