Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Send asynchronous email in website

Posted on 2010-08-31
10
Medium Priority
?
1,009 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
Industry Leaders: 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 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

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!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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