sending emails asynchronously.

simi d posted at 03-Jul-08 09:10

I  have read  article written by peter bromberg on  sending mails asynchronously in c#.

The same thing i have to implement on my asp.net application wherein i am sending emails to thousands of users say upto 2000.

now while sending mail their may occur error due to some users invalid mail ids . If this occurs i am collecting that datarow and creating and returning  datatable of failed mails in endinvoke method. since callback is used will sendmail method will be called automatically for failed rows.

Heres my code:

private delegate DataTable SendEmailDelegate(DataTable dt, string sMessage);

public void Calland SendMails()

{

SendEmailDelegate dc = new SendEmailDelegate(this.SendEmailAsync);

AsyncCallback cb = new AsyncCallback(this.GetResultsOnCallback);

IAsyncResult ar = dc.BeginInvoke(dtMember, sMessage, cb, null);

}

private DataTable SendEmailAsync(DataTable dtPurlMember, string sMessage)

{

DataTable dtTemp = new DataTable();

dtTemp = dtPurlMember.Clone();

bool bSendMails =false;

for (int i=0; i<dtPurlMember.rows.count-1; i++)

{

bSendMails = _classobj.SendeMails(parameters);

if (!bSendMails)

dtTemp.ImportRow(drPurlMember.rows[i]);

}

return dtTemp;

}

Please tell how this is feasible for thousands of records.




Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  sending emails asynchronously. - simi d  03-Jul-08 9:10:08 AM
      you can send mail in sql server. - Deepak Ghule  03-Jul-08 9:19:15 AM
          sending mails in asp.net application - simi d  07-Jul-08 2:24:08 AM
          sending mails in asp.net application - simi d  07-Jul-08 3:04:00 AM
      asynchronous email - Umapathy Kaliaperumal  03-Jul-08 9:30:20 AM
          sending mails in asp.net application. - simi d  07-Jul-08 2:25:44 AM
      See this for sending mails - Sujit Patil  03-Jul-08 11:58:38 PM
          sending mails in asp.net application. - simi d  07-Jul-08 2:28:05 AM
      Send Email Async... - santhosh kumar  04-Jul-08 2:12:26 AM
          sending mails in asp.net application. - simi d  07-Jul-08 2:30:15 AM
View Posts