|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SMTP and CDO.Message Object errorI have two theories. The first being that the program doesn't release SMTP resources and after a couple times running all the resources are used up. But if that's the case, then why does creating a new app always work? My second theory is that somehow SMTP holds a pointer the application calling it and it only lets each app have a couple pointers allocated to it. That's why new apps always work but then get locked out after a couple tests. I tried using garbage collection to free resources, but the SMTP object is a WinNT object and I can't instantiate it directly. So garbage collection hasn't helped solve the problem. After doing more testing, I found that if I leave the SMTP.ServerName empty, then it works everytime. The problem with this is that since I'm not specifying the corporate email server, then this isn't a reliable method for a production system. So this isn't a practical fix. Any ideas? Here is my test code: static void Main() { Application.Run(new Form1()); System.GC.Collect(); } private void Form1_Load(object sender, System.EventArgs e) { Send(per***@email.com", pers***@Email.com", "","test 2", "hello"); } public void Send(string From, string To, string CC, string Subject, string Body) { System.Web.Mail.MailMessage Email=new MailMessage(); Email.From=From; Email.To=To; Email.Cc=CC; Email.Subject=Subject; Email.Body=Body; Send(Email); Email=null; } public void Send(System.Web.Mail.MailMessage Email) { SmtpMail.SmtpServer = "smtp.ucsd.edu"; try { SmtpMail.Send(Email); } catch(Exception e) { string x; x=e.Message; MessageBox.Show(x); } } private void Form1_Closed(object sender, System.EventArgs e) { System.GC.Collect(); } Brian,
Any question about SMTP and CDO are difficult to answer, all was it alone by the fact that there are four different CDO products. - CDO.DLL : CDO version 1.2.1 - CDONTS.DLL : CDO version 1.2.1 for Windows NT Server (not the same as CDO version 1.2.1!) - CDOSYS.DLL : CDO for Windows 2000 - CDOEX.DLL : CDO for Exchange 2000 Server Than there are as well the security settings, which could be overuled for the 2000 version however from after that time I have not seen much here. However in your case I would try it in the newsgroup microsoft.public.dotnet.languages.csharp (And do it in plain text, a lot of people have newsreaders in which the way you sent it (HTML) is garbage) By the way showing that newsgroup is not because that you are not welcome here, however to give you a change on more answers. I hope this helps a very little bit. Cor |
|||||||||||||||||||||||