Ouch.... I think this code will earn you the "works on my machine" award from Gonzalo's signature....
As Gonzalo pointed out, this code runs on the server. It's not at all recommended to have web applications run client applications like this. What happens when you have 100 concurrent users? You'll end up with 100 instances of Outlook.
Also, who's going to enter the To address and press the Send button?
Are you running this on your local machine? If so, just for fun, try accessing the web site from a different machine. That will give you a clearer idea of what the server is, and what the client.
Finally, look at the System.Net.Mail namespace. It has all the functionality you need to send e-mail; with attachments as the following simple example demonstrates:
Code:
MailMessage myMessage = new MailMessage();
myMessage.From = new MailAddress("[email protected]");
myMessage.To.Add(new MailAddress("[email protected]"));
myMessage.Attachments.Add(new Attachment(@"D:\SomeFile.txt"));
new SmtpClient("Your.Mail.Server").Send(myMessage);
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of
Beginning ASP.NET 3.5 : in C# and VB,
ASP.NET 2.0 Instant Results and
Dreamweaver MX 2004
Want to be my colleague? Then check out this post.