This is a discussion on Sending Email Asynchronously within the .Net Development forums, part of the Programming & Scripting category; ok, so i am about to implement this So the current scenario is, i have to first insert a record ...
| |||||||
|
#11
| ||||
| ||||
| ok, so i am about to implement this So the current scenario is, i have to first insert a record in database, then send mails to all desired people. So after the insert, i should get all the emails of the people from database and then call this function to send mail?? Secondly, i dont want to anything if the send mail is failed or successful, so do i need this function SmtpClient_OnCompleted?
__________________ Get the Mantra! |
|
#12
| ||||
| ||||
| Yes you would need this function. Send the emails using the async function and then it'll just send them in the background without waiting for a response... The Smtp_OnCompleted function is called by the Async sending function.
__________________ Join the folding team |
|
#13
| ||||
| ||||
| ok, will this function Smtp_OnCompleted printout something if process is failed or successful? |
|
#14
| ||||
| ||||
| Quote:
|
|
#15
| ||||
| ||||
| Quote:
![]() thanx |
|
#16
| ||||
| ||||
| Ok, i am facing this error on red line Code: Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to PreRenderComplete event. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to PreRenderComplete event. 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, ";")
For Each email_to As String In arr_email_to
myMail.To.Add(New MailAddress(email_to))
Next
myMail.From = New MailAddress(ConfigurationManager.AppSettings("NoReply"))
myMail.Body = ""
myMail.Subject = "Update"
Dim mailBox As Object = myMail
AddHandler SmtpMail.SendCompleted, AddressOf SmtpClient_OnCompleted
SmtpMail.SendAsync(myMail, mailBox)
End Function
Code: GlobalClasses.SendMailUpdate(strEmailIDs) Last edited by micky; July 3rd, 2009 at 08:04 AM. |
|
#17
| ||||
| ||||
| ok added red part in .aspx file of this page in top line and it worked Code: <%@ Page Language="VB" Async="true" AutoEventWireup="false" Last edited by micky; July 3rd, 2009 at 07:57 AM. |
|
#18
| ||||
| ||||
| Do you think these lines in function SendMailUpdate above will send only 1 mail?? Code: For Each email_to As String In arr_email_to
myMail.To.Add(New MailAddress(email_to))
Next
Last edited by micky; July 3rd, 2009 at 08:08 AM. |
|
#20
| ||||
| ||||
| Quote:
![]() Is it a slow process RR, i mean i am receiving mails with some delay?? Also its showing all addresses in TO field in mail!! |
![]() |
|
| 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 |