|
Try using the async version of the Read method. And you should also treat the SendCompleted event. It's better using the async version because your application doesn't hang while the mails are being sent.
Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Hi,
Thanks for the reply.
"Try using the async version of the Read method." -- I hope you meant SendAsync method.
I have already tried with the SendAsync method, and handled the callback.
But it was of no help. So I have implemented another part of the application with asynchronous delegate invoke, to release the caller/client instantly, while the Send operation part is synchronous.
I think either the Framework, or the OS is maintaining a buffer somewhere, which is getting flushed when the process terminates. However this is what I think, and I can't solve this problem right now.
Thanks,
Deb
|
|
|
|
|
I wrote a Windows Service to send email. My applications put the necessary information in a database table, the emailer reads the table and sends the emails.
|
|
|
|
|
Yes, obviously writing a windows service is possible, but I need it as a WebService.
However, I can use other approaches as well, but I need to send all the mails.
As also, due to certain constraints, I can't use database, or even flat files for mail sending. I am using a derived Queue<t> with an overloaded EnQueue method, which fires a delegate whenever any item is added to the queue.
My problem is that, even if the smtpClient.Send call is executed successfully, all the mails are not sent until the running thread/process is killed.
I can't understand the cause of the problem.
Say I fired Send method 100 times. I am getting no exceptions, and all 100 calls are going through fine. But all 100 mails are not sent until I close the process from which Send method is fired.
It will be very helpful, if I atleast get an explanation why this is happening, if not how to solve this.
Thanks.
Deb
|
|
|
|
|
does your app terminate after the Console.Read() ? If so you're right about it being a buffer issue. Check the smtpClient class for a Flush method. IF for some reason there isn't one the Close or Dispose methods will do the same thing as shutting down the app. Just remember you'll need to reallocate a new smtpClient the next time you need to send.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Yes, the app terminates after the Console.Read().
I am still in problem as SmtpClient class has no flush method.
And I cannot Dispose off any client, as there is an implementation of client pooling. So I am creating the clients with identical credentials, and Host settings, and maintaining a queue of specified number of clients.
I am thinking of recreating the client list after some idle time, but I am not sure.
But is it really some buffer issue at the SmtpClient end, or at some other end?
Because if it is at some other end, I am not sure whether disposing off the clients will flush it. And where is the buffer?
Deb
|
|
|
|
|
|
hi guys,
i am stuck with this problem for last 2 days,
i have set the timeout property to 60 , still it does not send emails untilli uninstall the service.
please help!happy coding!
|
|
|
|
|
Hello,
I have a lame question about passing a string variable from one aspx.cs file to another aspx.cs file.
In the first page I am retrieving the current server address as so:
psServerAddress = Request.ServerVariables["Server_Name"];
psServerAddress is declared in the second aspx.cs file.
Goal: I want get() and set() methods to retrieve the current server name and then access it in
my second aspx.cs file.
I don't want to use GetQueryString
|
|
|
|
|
You could try posting this question on the ASP.NET forum, but I might give you an idea. You can create two methods Get, Set. In the page you want to call them you have to reference the page that contains those methods to gain access to them. To reference a page you can use the <%@ Reference page="..." />. For more details see this
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
I need to pass the server name because the user control in reference is built in a separate project. The dll is built into the project I am currently working in. The problem is, at the time the user control is instantiated, we are screen scraping from an insurance carriers site. I know it sounds confusing, but trust me, at this time I cannot do the request.server... to retrieve the current server from where we originated.
|
|
|
|
|
|
Hi guys,
I have a slight problem. I have a SQL DB with two tables, i have a client table and an invoices table. I have two forms one for each of the tables. On the Invoice form I have a comboBox which is linked to the ClientID on the Client Table. My problem here is that when a client ID is selected I need to display the Client name and address details in a label or text box on the Invoice form.
Can sombody please advise me what to do or how to do this? I have tried a few things but it doesn't seem to work. I have tried linking the text box to the Client table but it keeps displaying the same client name regardless of the ClientID selected in the comboBox.
Any help or advice or a reference to read would be greatly appreciated as I am prepared to read up on it but have not been able to find a matching reference.
Striving for perfection is like swiming upstream, Difficult, but not impossible.
|
|
|
|
|
You have to link the text box on the SelectedIndexChanged event of the combobox. There you should create specify the datasource for the textbox/label or whatever you use.
Hope it helps
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
Thanks mate but maybe I am a little stupid but how? Sorry bout this.
|
|
|
|
|
ok i know this must be a silly question, but im new to c# and still learning.....
I am trying to display a float value to the console, but it only appears as a whole number. (I am trying to display the average of an array of numbers)
This is what i have;
float result = Total/NumberArray.Length; //to store avg value in flaot var
.
.
Console.WriteLine("Average " + result); //to show value on screen
Where Total is The sum of the numbers
NumberArray.Lenghth is lenghth of array
For example (20+20+10)/3 = 16.66666
What i see on the screen is 16
Help would be appreciated???
Cheers
|
|
|
|
|
Try this:
float result = (Total*1.0)/(NumberArray.Length*1.0);
.
.
Console.WriteLine("Average " + result);
If you divide 2 integers, even if you store the result in a float, the result is also integer, so try a small "cast"
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
a real cast is more efficient than your kludge. In any event you don't need to cast both numbers, just the one.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Thanks Andrei
How silly of me, i should of thought of type 'casting';)
this also works
float result = ((float)Total/NumberArray.Length);
Cheers
|
|
|
|
|
I know that casting also works, it was just another way of doing things
There are 10 kinds of people: those who understand binary and those who don't
|
|
|
|
|
I assume total is also an integer. IF so what's happening is that you're doing integer division, getting an integer result and then converting the int into a float.
What you need to do is cast one of the ints into a float before doing the division.
float result = (float)Total/NumberArray.Length;
Depending on order of operations you might need a second parenthesis to get the desired result.
float result = ((float)Total)/NumberArray.Length;
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Yes thanks Dan
Cheers
|
|
|
|
|
Also, you may want to limit the number of decimal places shown, you can do that like this:
float fTest = 123.456789f;
string sTest = fTest.ToString("N3");
that would put it at 3 decimal places, N5 would show 5 decimal places and so on. Just thought you might like to know. Incase you didn't already.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Ooh - you're hitting an issue that regularly causes confusion and gets a lot of people hot under the collar about .NET. Basically, the issue is that the Total value is an integer. You need to cast the result to a float so this would become float result = (float)Total/NumberArray.Length;
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello
I am kind of new to C#(2.0) and MS SQL 2005, I am battling to write code (windows app C#), that can check Sql table to see if a record already exist. I have a table in sql called [Resources] with a PK called(Personnelno), i am trying to write a stored proc that can check if a [personnelno] exist in the table. if it exist it shouldn't save the record, else save it.
The application is three tiered [DAL, Business object and Presentation], can anyone please show me how do i call this stored proc through this layers until to the presentation layer. i'm trying to show messagebox to let user know that the record already exist, so he or she can change it.
Thanks.
N. Gazide
|
|
|
|