This is a discussion on Sending Email Asynchronously within the .Net Development forums, part of the Programming & Scripting category; Originally Posted by micky Ok, its sometimes sending, sometimes not Is it a slow process RR, i mean i am ...
| |||||||
|
#21
| ||||
| ||||
| Quote:
![]() Just realised that the for each loop is just adding each address to the to property, not sending the email as well.... The delay may be in your mail server...If you still have the whole function I posted, try setting the async flag (check_error, errorCheck or something) in the email function to check for errors and not send asyncronously to see if it makes any difference...
__________________ Join the folding team |
|
#22
| ||||
| ||||
| Quote:
I'll try to check without async.
__________________ Get the Mantra! |
|
#23
| ||||
| ||||
| Quote:
Code: Public Shared Function SendMailUpdate(ByVal emails As String)
Dim SmtpMail As New System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings("SmtpServer"), 25)
Dim myMail As New MailMessage()
'SmtpMail.DeliveryMethod = SmtpDeliveryMethod.Network
Dim arr_email_to As Array = Split(emails, ";")
myMail.From = New MailAddress(ConfigurationManager.AppSettings("NoReply"))
myMail.Body = ""
myMail.Subject = "Update"
Dim mailBox As Object = myMail
AddHandler SmtpMail.SendCompleted, AddressOf SmtpClient_OnCompleted
For Each email_to As String In arr_email_to
myMail.To.Add(New MailAddress(email_to))
SmtpMail.SendAsync(myMail, mailBox)
myMail.Remove(0) 'not sure about the remove method, so might have to check if you use the index or the email address string.
Next
End Function
|
|
#24
| ||||
| ||||
| Ok, i'll try it RR. But there is no remove property for myMail. |
|
#26
| ||||
| ||||
| Quote:
Quote:
Last edited by micky; July 4th, 2009 at 03:44 AM. |
|
#27
| ||||
| ||||
| Quote:
Code: <%@ Page Language="VB" Async="true" EnableEventValidation="false" So i assume that i cant have that SmtpMail.SendAsync line in For loop. But it just keep sending all emails in TO field. I think its the problem with system.net.mail.mailmessage.to, its a collection address Any ideas anyone? |
|
#28
| ||||
| ||||
| Ok, i made some changes and it seems to be working now. Its sending mail one by one now. Thanx RR Code: Dim arr_email_to As Array = Split(emails, ";")
For Each email_to As String In arr_email_to
Dim SmtpMail As New SmtpClient(ConfigurationManager.AppSettings("SmtpServer"), 25)
Dim myMail As New MailMessage()
myMail.From = New MailAddress(ConfigurationManager.AppSettings("NoReply"))
myMail.Body = "Update"
myMail.Subject = "Update"
myMail.To.Add(New MailAddress(email_to))
SmtpMail.SendAsync(myMail, Nothing)
Next
|
|
#29
| ||||
| ||||
| M, my only comment on this thread is regarding disabling Event Validation. Event Validation reduces the risk of unauthorized postbacks and callbacks. I would look into a better solution for this.
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#30
| ||||
| ||||
| Quote:
But ironically, now the code is showing emails in TO field again and also sending mails with different number of recipients to same person. Darn |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sending Emails Using ASP.NET | richyrich | .Net Code Samples | 5 | July 6th, 2009 04:21 AM |
| [Email] Sending HTML email... | bryceowen | PHP Development | 3 | April 8th, 2009 07:28 PM |
| Excel and Email | Chrissy | ASP Development | 10 | February 16th, 2009 09:11 PM |
| Sending Email with ASP and CDOSYS | jmurrayhead | ASP Code Samples | 1 | November 13th, 2008 09:26 AM |
| Sending Email using CDOSYS & Classic ASP | richyrich | ASP Code Samples | 0 | March 17th, 2008 09:52 AM |