C# .NET - how we send 1 lac email send through asp.net c# fast way

Asked By aashish sharma on 18-May-09 02:24 AM
how we send 1 lac email(Bulk of email message) send through asp.net c# in fast way plz reply me its a very important for me.. anyone can help me

Re

Ravenet Rasaiyah replied to aashish sharma on 18-May-09 02:31 AM
Hi

Best idea make common thread function with your email data collection.

Then make like block operation to your 100K records, like for example make four block function to hand with four background thread 25K,25K,25K,25K.

Execute same time above four thread like simultaneously.
Then it work like multi thread operation to send emails.
need any more code level, just drop a post here
thank you


re

Rao B replied to aashish sharma on 18-May-09 02:41 AM

I think you have to use third party tools for bulk email.

Check this link

http://www.componentsource.com/features/email/asp-net-webform/visual-csharp-net/index.html

Alice J replied to aashish sharma on 18-May-09 02:41 AM

Hi,

Following is the instructions to develop bulk email sending application. The code itself is attached as zip file. Make use of them!

Find code here: http://www.eggheadcafe.com/fileupload/156608190_emailer.zip


Introduction

I use this code to collect related emails & send newsletters to my customers. I don't use it to send Junk mails to others, so I do not know about the filtering for different mail servers and these kind of usages. I also use it to extract emails from a complex text file (containing email addresses and other texts).

Using the code

There are two parts: first gathering and collecting email addresses in database and the second is sending email. For extracting emails easily copy the text containing emails & paste in to the textbox AddBulkEmail.aspx. It will extract and save email addresses to the MailingList.mdb file. After that, in Default.aspx I send my emails to the addresses.

Before using, set the web.config file. I set 4 variables in web.config:

  • SMTPServerName is the name of the mail server which you are working with.
  • SampleEmailAddress is the email address which you send sample email for testing and checking the content of your email before sending to the others.
  • UDLPath is the address of the file which includes the connection string.
  • MatchExpression, there is no need to change it, I placed it here because I thought may be some times I want to change the filtering for extracting emails; and easily I change the web.config file.

    In the main.udl file set your physical path for MailingList.mdb.

(The name of application which I tested in my local machine is http://localhost/emailer, so you may need to create it in your IIS)

Email send in asp.net c#
aashish sharma replied to Ravenet Rasaiyah on 18-May-09 02:42 AM
Hi

i m new in asp.net c# and i have no good knowledge in threading and also in asp.net if u can give me some refrence link it will be good plz let me know..or send me code of it..
and thanks in advance and reply
Santhosh N replied to aashish sharma on 18-May-09 02:45 AM

I would recommend this asynchronous way of sending mails by Peter..

http://www.eggheadcafe.com/articles/20030720.asp

or else, if you have mail ids in DB, then this would be a better bet..

http://www.codeproject.com/KB/IP/smartmassemail.aspx

ok
Ravenet Rasaiyah replied to aashish sharma on 18-May-09 02:46 AM
hi

Check couple of this links.Here great sample to send bulk emails

http://www.codeproject.com/KB/applications/tajanemailer.aspx

thank you
hi
aashish sharma replied to Ravenet Rasaiyah on 18-May-09 03:08 AM
Hi

thanks for reply but i want it works very fine...plz let me know any other solution
great
Ravenet Rasaiyah replied to aashish sharma on 18-May-09 03:09 AM
end of post
hi
aashish sharma replied to Ravenet Rasaiyah on 18-May-09 03:27 AM
how i send mail in very fast way plz let me know what is the main thing abut it ....and also let me know can i send bulk mail through my domain or i need any service form hosting server provider.
Ravenet Rasaiyah replied to aashish sharma on 18-May-09 03:47 AM
Hi

Normally you have one port to send email using SMTP. so i think if you are try sen d 100000 email you need use the thread as like as i said.that;s best solution to these kind of work.thats we need start multi thread to do as bulk operation.when we do like this way its will faster and quick to send emails.

But when we are use multi thread your email server must have support to accept parallel request.( i hope its default)

for email you don't need any providers Only you need SMTP enable in your server.
You write code for that with multi  thread it will work with fine man

here start points
For the threading you can use this sample directly
http://dotnetperls.com/Content/BackgroundWorker-Introduction.aspx
Under the DoWork event you could call like this method


thank you
public override bool Dispatch(List<EmailMessage> list)
{
List<EmailMessage> failurelist = new List<EmailMessage>();
//Gets SmtpSettins from the config

SmtpClient client = new SmtpClient();

foreach (EmailMessage em in list)
{
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress(em.EmailFrom);
message.To.Add(new MailAddress(em.EmailTo));
message.Subject = em.EmailSubject;
message.Body = em.EmailBody;
message.IsBodyHtml = em.IsHtml;

client.Send(message);
// on error, loop so to continue sending other email.

}
catch (Exception e)
{

failurelist.Add(em);
}
++totalSent;
}
if (failurelist.Count > 0)
{
ProcessFailedMessages(failurelist);
return false;
}
return true;
}

Thank you
hi
aashish sharma replied to Ravenet Rasaiyah on 18-May-09 04:06 AM

but i want to send mail in asp.net not in desktop application and background worker is not in asp.net web application so i do it plz let me know
Cool
Ravenet Rasaiyah replied to aashish sharma on 18-May-09 04:10 AM
Hi

No there is no component on the toolbox, but you could add like manual coding like this way

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;

/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{

System.ComponentModel.BackgroundWorker worker;
public Class1()
{
//
// TODO: Add constructor logic here
//
}

private void ThreadStart()
{
worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
worker.RunWorkerAsync();

}

void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
throw new NotImplementedException();
}

void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
throw new NotImplementedException();
}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
throw new NotImplementedException();
}
}

thank you
sending mail
harendra singh replied to aashish sharma on 18-May-09 08:45 AM

Make one class

using System;

using System.Collections.Generic;

using System.Text;

using WdQuizBL.BO;

using System.Net.Mail;

using System.Data.SqlClient;

using Microsoft.Practices.EnterpriseLibrary.Data;

using Microsoft.Practices.EnterpriseLibrary.Common;

using System.Data;

using System.Data.Common;

public class SendToFriendFacade

{

   

public string SendMail()

{

//Boolean retVal;

string errorMsg = "";

try

{

SmtpClient objSmtpClient = new SmtpClient();

MailAddress sender = new MailAddress(_sm.NoReplyEmail, _sm.SenderName);

MailMessage msg = new MailMessage();

objSmtpClient.Host = _sm.Host; //your host addres

objSmtpClient.Port = _sm.Port;// port that ur using

msg.From = sender;

msg.To.Add(_sm.FriendEmail);

msg.Bcc.Add(test@test.com);

msg.Subject = _sm.Subject;

msg.IsBodyHtml = true;

msg.Body = CreateMailBody();

msg.BodyEncoding = System.Text.Encoding.UTF8;

msg.SubjectEncoding = System.Text.Encoding.UTF8;

objSmtpClient.Send(msg);

errorMsg = "";

}

catch (Exception ex)

{

errorMsg = ex.Message;

}

return errorMsg;

}


private string CreateMailBody()

{

 return html;

}

}

make object of class and use this function

Sameer replied to Ravenet Rasaiyah on 14-Jul-10 02:36 AM

Hello Bill Look;

I need ur help in sending mass emails.

As you said, to Execute same time the above 4 thread simultaneously. How can it be done.

Can you give me some code level help.

I am using VB.NET (desktop).

I have written a code using threads, for sending mass emails. But the performance is not satisfactory.

I wanted to perform it as http://ikf.co.in/estorm.asp which is third-party software.


Can you help me..


Thanks

Sameer