Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All


I just want to call a Web service in asynchronous mode.
So that my application will not wait for the completion of sending the mail till the end.Once i call the web service,my application should go on with "Successfully send mail" and the sending email should run in the background.


Can anyone give the code samples.

Here is the code in synchronous mode:

using System.Web.Services;

/// <summary>
/// Summary description for KlassAktMailService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class KlassAktMailService : System.Web.Services.WebService
{

    public KlassAktMailService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string Send_Email(string strEmailAddrTo, string strEmailAddrCC, string strSubject, string strBody, string strFileName)
    {
        EmailAlert NewMail = new EmailAlert();
        return NewMail.SendEmail(strEmailAddrTo, strEmailAddrCC, strSubject, strBody, strFileName);
    }
}



I want the code for asynchronous mode.



Thanks and Regards
froxy
Posted

1 solution

Have a look at below link for "Asynchronous Web Service Call".
http://msdn.microsoft.com/en-us/library/55xs7d7f%28v=VS.90%29.aspx

You may think of sending Emails Asynchronously from the Web Service it self, for that have a look at below links.

http://wiki.asp.net/page.aspx/536/send-asynchronous-mail-using-aspnet/

http://www.asp.net/general/videos/how-do-i-send-email-asynchronously-with-aspnet
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900