Solved

Send asynchronous email in website

Posted on 2010-08-31
10
996 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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