473,414 Members | 1,667 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,414 software developers and data experts.

SMTP and CDO.Message Object error

In my Win app I found that using the SMTP object doesn't release resources after closing the application. During testing I have to open and close the app many times and I found that after about three times it locks up when I call the Send() method and returns the error "Could not access CDO.Message Object". I found that if I create a new Win App and copy and paste the code into it, then it runs fine for the first couple of times and then starts returning that error. I also noted that I can send as many email messages as I want and they all get sent with no error as long as I don't close the program. Unfortunately, not closing the program isn't possible and I'm creating new apps constantly as I test my code.

I 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(pe****@email.com", pe*****@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();
}

Dec 15 '05 #1
1 2118
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
Dec 16 '05 #2

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

Similar topics

2
by: Janna Deegan | last post by:
Hello all, First off, if there is a better place to post for an answer to this question, please feel free to point me there. I have some very strange behavior happening with my System.web.mail...
0
by: Charles Fineblum | last post by:
Hi: I'm trying to send e-mail using SMTP class. I'm getting error "Could not access CDO.Message object." I know my SMTP server is working because I can drop a text file message in "Pick-up"...
3
by: Chris Davoli | last post by:
I'm trying to send email from an aspx page. Here is my code. It gives me an error message "Could not access 'CDO.Message' object." What do I need to do? This is on my local machine and I...
5
by: Prashant Barnwal | last post by:
Hi, This message i get whne i try to send mails theu my app server. any idea where and what to look for? It works fine in Dev bed. Guide me to apprpriate news group if its not the right place. ...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
5
by: Carmine [www.thetotalsite.it] | last post by:
Hi everyone, I get a really odd error while using SMTPClient.Send() function in ASP.Net. The error is the following: Dim smtp As New Net.Mail.SmtpClient("smtp.thetotalsite.it", 25) Dim bodyMSG...
4
by: Brian | last post by:
Hello all, we don't actually host our own server but still should work the same. Here is the error message i get "error mailbox unavailable. The server response was: must be authenticated code...
7
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.