Connection open while sending Email with SmtpClient
-
hi, when sending mails using SmtpClient, does it open connection each time I do .Send() if yes how can i avoid it? If no what is the mechanism used to send Email. cheers
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
Sagar K. Godbole wrote:
does it open connection each time I do .Send()
I dont think you mean to say that you need only 1 connection until all the mails you want to send are handed over ? If this is the case then you might be unhappy that there is no setting which can persist the connection. ( though i havent checked it myself, it is my perception )
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
-
Sagar K. Godbole wrote:
does it open connection each time I do .Send()
I dont think you mean to say that you need only 1 connection until all the mails you want to send are handed over ? If this is the case then you might be unhappy that there is no setting which can persist the connection. ( though i havent checked it myself, it is my perception )
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
yes i meant that. .send() is a blocking call. i need to send mails at one go with one connection, this is to get rid of Timeout wait in .Send() which takes place for each Mail that i need to send and if there are too many then its that much of wait for my application,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
coolestCoder wrote:
mean to say that you need only 1 connection until all the mails you want to send are handed over
this is what i mean ! Is it possible !
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
yes i meant that. .send() is a blocking call. i need to send mails at one go with one connection, this is to get rid of Timeout wait in .Send() which takes place for each Mail that i need to send and if there are too many then its that much of wait for my application,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
i have arround 300-500 notifications to send at one go.. do you mean those many Threds...:sigh: I thought i could do a single connect and if it fails i will come to know immidiately.... right now ihave a collection of MailMessage objects which i'mpreparing in advanc and then sending it one by one Thanks,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
i have arround 300-500 notifications to send at one go.. do you mean those many Threds...:sigh: I thought i could do a single connect and if it fails i will come to know immidiately.... right now ihave a collection of MailMessage objects which i'mpreparing in advanc and then sending it one by one Thanks,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
no , notifications are per action like Task Created,User registed etc.. if they are same is there way to do bulk send? thanks,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
yes i meant that. .send() is a blocking call. i need to send mails at one go with one connection, this is to get rid of Timeout wait in .Send() which takes place for each Mail that i need to send and if there are too many then its that much of wait for my application,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
no , notifications are per action like Task Created,User registed etc.. if they are same is there way to do bulk send? thanks,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
i have arround 300-500 notifications to send at one go.. do you mean those many Threds...:sigh: I thought i could do a single connect and if it fails i will come to know immidiately.... right now ihave a collection of MailMessage objects which i'mpreparing in advanc and then sending it one by one Thanks,
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
Hi, I thought this would also be of your interest. http://www.codeproject.com/cs/internet/smartmassemail.asp[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
-
Yes, add the people to the "to" list. Instead of one email per recipient, add them to the recipient list, and send one email.
;P well thanks, but thats the way emails are already generated, with multiple To,CC addresses..
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
thanks, internally it will spawn a thread to do my work, this will definately fasten up things, but if i can get that single connection for sending mails it will be great SmtpConnection class is there but its not exposed otherwise i could have achived behaviour seamlessly.
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
;P well thanks, but thats the way emails are already generated, with multiple To,CC addresses..
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
You can also eliminate the round trip throught the server:
SmtpMail.SmtpServer = "localhost";
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]=1;
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"] = "C:\\Inetpub\\mailroot\\Pickup";
SmtpMail.Send(eMail); -
You can also eliminate the round trip throught the server:
SmtpMail.SmtpServer = "localhost";
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]=1;
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"] = "C:\\Inetpub\\mailroot\\Pickup";
SmtpMail.Send(eMail);edboe wrote:
SmtpMail.SmtpServer = "localhost";
its from System.Web.Mail which has been depricated now.
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.
-
Hi, I thought this would also be of your interest. http://www.codeproject.com/cs/internet/smartmassemail.asp[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
i have gone through that already,but working with MSSQL 2000 i do not have sql server 2005 nice article though,. thanks
------------------------------ Its not the fall that kills you; it's the sudden stop at the end.