useing System.Net.Mail in Net 2.0

Useing C# and VWD enviroment with the Test server in VWD. Code for Mail does not work in 2.0, get an error like this:

 System.Net.Mail.SmtpException was unhandled by user code
 Message="Failure sending mail."
 line 42 which is the smtp.Send(email) line.

Code for the old way in 1.1 works just fine, here is what I use (email is bogus for this)

The commented line are for Net 1.1 which works. Any ideas what I need to do? Thanks

using System.Net.Mail;
//using System.Web.Mail;

protected void Button1_Click(object sender, EventArgs e)
  ERMessageSender();  //just for testing
   //string errorMessage="";
   //errorMessage+="This is a test error message...";
   //MailMessage newMail = new MailMessage();
   //newMail.From =""MyName@********.com"";
   //newMail.Subject="Just Testing";

void ERMessageSender()
   MailMessage email = new MailMessage();
   email.From = new MailAddress("MyName@********.com");
   email.To.Add(new MailAddress("MyName@********.com"));
   email.Subject = "Error message reporting with 2.0";
   email.Body = "This is a test to see if it will work";
//send the message
   SmtpClient smtp = new SmtpClient("");

8/23/2006 2:15:15 AM 93655 articles. 6 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 19
Get it on Google Play
Get it on Apple App Store

8/23/2006 2:26:01 AM


   could you specify the SmtpMail.SmtpServer you used in 1.1?  I don't see you set that in the comment codes;

8/23/2006 2:49:41 AM
Thats all there is, is what is showing. I used the sample from the book 'Beginning ASP.NET 1.1 with Visual C#. 2003' by Wrox. It works in both the test Server in VWD and on the Server with Win 2003 and IIS 6.0. I believe that I have tried the links given in the previous response but I will try again and see what happens. Thanks for the help so far.
8/23/2006 1:41:27 PM


   it seems to "work" in 1.1, because you used Server.ClearError(); .a  COMException will be throwed out unless you set the correct SmtpMail.SmtpServer.

   And in 2.0, you must set a valid SmtpClient.


8/24/2006 5:39:24 AM
Been doing more research and am pointed in the right direction now. Thanks for the Info
8/24/2006 1:44:24 PM
I posted to quick on the last one. I have commented out the 'Server.ClearError()' and it still works for me. That is using IIS 6 also. No error messages until I try to use 2.0 section, and that is straigt from the site posted in the replys. I'm still confused, but trying. thanks
8/24/2006 4:04:18 PM

Similar Artilces:

.Net 2.0 Web application using is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one web application using which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Access .Net 2.0 Application from .Net 2.0 Web Site
I need to populate a specific form in a .Net desktop application from a .net web application.  Is there an easy way to go about this? Hi, Based on my understanding, you want to start an executable application from your ASP.NET websit, right? We can invoke Process.Start method ( to launch an executable application from ASP.NET application. Note: Please keep in mind, the ASP.NET application is running on the server, so it will start the executable application that exists in the server.   I look...

.net 2 beta 2 - System.Net.Mail
Hi guysI'm using the System.Net.Mail namespace in .net version 2, beta 2, to send out some HTML formatted e-mails.However, for some reason when the e-mail are sent out some of the full stops from the e-mail are removed.For example, part of the e-mail contains this code<img src="" alt="">But this is what the code is like when the e-mail source code is viewed<img src="" alt="">Is this a known bug in beta 2? If so, where can I view a list of known bugs an...

About: how can i send a MIME(Text und Html Format) Mail by System.Net.Mail und .Net 2.0
Helle to all, I hope that someone can help me. I need to implement a programm to send newsletters. The newsletter Format can be Html, Text and MIME(Html and Text). when using CDONTS library man can set MailFormat = MIME. But i use System.Net.Mail and there are only text or html Format. Can someone tell me how can i use System.Net.Mail to send a MIME Mail? Thanks Best Regards Pinsha perhaps this link can help: this world there are 10 types of people, those that know binary and those who don't....

How to get new web app to use .NET 2.0 on Win2K server using .NET 1.1 as default framework?
I have .net framework1.1 and 2.0 on our server running win2K. i have existing applications that uses 1.1, i also have a new app that use 2.0.  how can i set my new .NET 2.0 app to point to 2.0 without messing up my existing .NET 1.1 apps? To specify the ASP .Net version fro a web application, do the followingIn IIS Manager select the web application -> Properties -> ASP.Net TabSelect  ASP.Net version you want to use for the applicationRegards,PrashantDont forget to click "Mark as Answer" on the post that helped you. But I am running Win2K...

web.config problems when upgrading from .NET 2.0 Beta to .NET 2.0 release version
We uninstalled .NET 2.0 Beta and replaced it with .NET 2.0 release version.  And it messed everything up.  All applications now give weird errors indicating the lack of web.config files, despite the fact that they already have web.config files in place.  For example, the following error occurs even though the web.config file has <customErrors="Off">: Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for securit...

.DLL compiled with .NET 1.1 to be used in Web app done in .NET 2.0
Hi all,If I have a bunch of business objects that where compiled in .NET version 1.1, would it be possible for my ASP.NET (done in .NET 2.0) application to pick up these objects (.dll file) and start to use them?(Would be great if some-one could provide some form of documentation on this)ThanksTryst Hi Tryst, This should work fine.  In general, you can use V1.1 assemblies with V2.0 applications.  The reverse, though, is not true. Hope this helps, Scott ok, cool.ThanksTryst Comparative study on VS .Net 2003 and VS.Net 2005 .Net Framework versions used are ver...

Error with using .Net 3.0 instead of .Net 2.0
Hi,  I have recently made a website in microsoft visual web developer 2005.  When I have uploaded my site to my host I am having trouble.  when I visit the page I get an error message.  My web hosting company does not support .net 3.0 but instead use .net 2.0.  My website is made with file extensions .aspx.  I am usure how to tell what version of .net I am using and wether this is the only cause.  At first there was a 403 error occuring. Help would be much appreciated as I have been struggling with this for some time. The version...

Bad web.config in AJAX.NET 1.0 under .NET 2.0 Express
My setup is MS.NET v2.0 with the C# and Web Express editions of 2005. I also installed the AJAX 1.0 release with the respective toolkit as indicated in the AJAX.NET site. However, when I create a new project I am presented with the usual bare bones default.aspx and the web.config. However the web.config shows a lot of warnings and errors.One of them was being that the "requiredPermission" (or something like that) attribute was not recognized. Somewhere on the net there is a post of a correction to the DotNetConfig.xsd schema file in VS.2005 so I used it and it got rid of THAT warning.&n...

Sending SMS using or using or
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

i ve got System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=, failed. exception
hi everyone i created windows form user control and i embedded it to web for , my user control sends mail using by System.Net.Mail library but when i open my web site and click to send button that on my user control  i ve got this exception System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.    what can i do ? my best regards ..    Couple of questions: 1) Are you running this from an IIS installati...

.NET 3.0 or .NET 2.0?
I'm going to move my exiting software to .net soon. I'm just wondering if I should wait for the .NET 3.0 framework to be released or if I can start with the 2.0 now? I'd say you can go ahead and move your code to .Net 2.0 as .Net 3.0 uses the CLR version 2.0.Basically, .net 3.0 is .net 2.0 PLUS some new features for presentation (GUI), communication and workflow process.  So the compiler as well as the language features used by the 2.0 runtime will be the same in 2.0 and 3.0"Never argue with an idiot; He will drag you down to his level and beat you with experienc...

Web resources about - useing System.Net.Mail in Net 2.0 -

Mac App Store - Call of Duty®: Black Ops
Get Call of Duty®: Black Ops on the Mac App Store. See screenshots and ratings, and read customer reviews.

pentacon bike pr0n - Flickr - Photo Sharing!
I promise I'll never touch a 35mm camera again pentacon six tl sonnar 180mmf2.8 kodak bw400cn Bordeaux vue d... Photographies By Colin Alexander ...

Sign in Sign up You are on Mobile because you are using an old version of Internet Explorer. Learn more here The Associated Press @ AP Ark. legislators ...

Wikipedia:Graphic Lab/Image workshop/Archive/Jan 2009 - Wikipedia, the free encyclopedia
In the first image (the black and white), are you having any trouble seeing the white lines against the black backdrop? I can increase the line ...

Tomsondev Blog - My Company EDV Systemhaus GmbH BestSolution was founded in 2002 by three partners and comprises today different projects for wellknown business-partners ...

piper - Android Police - Android News, Apps, Games, Phones, Tablets
... a year ago? Well the campaign is over and the gadget is on sale now. Once you get yours in the mail, you'll need to set it up and start useing ...

More whining from Rhonda Locklear aka Squaw Dial-up » AWGBlog
Search AWGBlog Home About Liberal Lexicon (updated 3-12) Who’s Online F.A.Q. Contact « Dail-up puts my family at a disadvantage says whiners ...

Wen Ho Lee to Be Released
Where Asian America Gathers

Bagchee E-Gift Cards
Give the Perfect Gift. In an instant. E-Gift Cards are send by email within minutes and can be redeemed online.

[...] Podcast #27: CSS Workflow and Tools « Ask Different Blog: [...]
current community chat Ask Different Ask Different Meta more communities Explore other Stack Exchange communities on Stack ...

Resources last updated: 12/1/2015 9:27:06 AM