Solved

Send asynchronous email in website

Posted on 2010-08-31
10
964 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
10 Comments
 
LVL 7

Expert Comment

by:Inteqam
Comment Utility
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
Comment Utility
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
Comment Utility
public void SendEmailInSeparateThread()
{
      try {
            t = new Thread(this.SendEmail);
            t.Start();
      } catch (Exception ex) {
      }
}
0
 

Author Comment

by:calypsoworld
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 7

Expert Comment

by:Inteqam
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
sorry for thr C# - VB mixing
0
 

Author Comment

by:calypsoworld
Comment Utility
OK.
I'll try this solution.

Thank you!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now