?
Solved

Send asynchronous email in website

Posted on 2010-08-31
10
Medium Priority
?
1,010 Views
Last Modified: 2012-05-10
Hi!

I have some tasks in my website that sends emails.

The problem is that the email sending may be slow, forcing the user to be waiting, sometimes, too much.

How can I do something that do all the stuff and sends the email in background, without disturbing the normal system process.

Maybe using Asynchronous method to send email... I don't know.
I've tried this tutorial <http://www.asp.net/general/videos/how-do-i-send-email-asynchronously-with-aspnet> but it didn't worked. Actually, I'm not sure if it's what I need.

Thanks in advance!
0
Comment
Question by:calypsoworld
  • 5
  • 4
9 Comments
 
LVL 7

Expert Comment

by:Inteqam
ID: 33573301
i have this method in my class

   Public Sub SendEmailInSeparateThread()
        Try
            t = New Thread(AddressOf Me.SendEmail)
            t.Start()
        Catch ex As Exception
        End Try
    End Sub
0
 

Author Comment

by:calypsoworld
ID: 33579255
Thank you for reply!

I can't make this code work in C#, even changing the AddressOf to new EventHandler...
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33582373
public void SendEmailInSeparateThread()
{
      try {
            t = new Thread(this.SendEmail);
            t.Start();
      } catch (Exception ex) {
      }
}
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:calypsoworld
ID: 33582591
public void SendEmailInSeparateThread()
{
System.Threading.Thread t;
      try {
            t = new Thread(this.SendEmail(param1, param2);
            t.Start();
      } catch (Exception ex) {
      }
}

ERROR:
Error      6      The best overloaded method match for 'System.Threading.Thread.Thread(System.Threading.ParameterizedThreadStart)' has some invalid arguments
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33584208
Why are you sending Parameters? for that use this

public void SendEmailInSeparateThread()
{
System.Threading.Thread t;
      try {
            t = new Thread(new ParameterizedThreadStart(SendEmail));
            t.Start(Param1,Param2);
      } catch (Exception ex) {
      }
}
0
 

Author Comment

by:calypsoworld
ID: 33608061
Still not working... Method sendEMailContactForm has 4 arguments, all String
 
                 Thread t;
Error 5      t = new Thread(new ParameterizedThreadStart(this.sendEmailContactForm));
Error 6      t.Start("ok","ok","ok","ok");

Error      5      No overload for 'sendEmailContactForm' matches delegate 'System.Threading.ParameterizedThreadStart'

Error      6      No overload for method 'Start' takes 4 arguments
0
 
LVL 7

Accepted Solution

by:
Inteqam earned 2000 total points
ID: 33608198
My mistake
Start cannot take multiple params, so you need to put your Params in ONE array, or ONE class and pass it

so instead of

                 Thread t;
Error 5      t = new Thread(new ParameterizedThreadStart(this.sendEmailContactForm));
Error 6      t.Start("ok","ok","ok","ok");


use
class MyParams
   public P1 as string
public P2 as string
public P3 as string
public P4 as string
end class
                 Thread t;
Error 5      t = new Thread(new ParameterizedThreadStart(this.sendEmailContactForm));
dim MP as MyParams
MP.P1 = "ok"
MP.P2 = "ok"
MP.P3 = "ok"
MP.P4 = "ok"
Error 6      t.Start(MP);

function sendEmailContactForm(MyPar as MyParams)
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33608199
sorry for thr C# - VB mixing
0
 

Author Comment

by:calypsoworld
ID: 33608348
OK.
I'll try this solution.

Thank you!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question