Solved

Send asynchronous email in website

Posted on 2010-08-31
10
991 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 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