using this source code i made a email sender type of thing, is there a way which i can edit this to like send emails in bulk, run a service in the background because when i press send it take a while to send?
<Code>
MailAddress from = new MailAddress((textBox2.Text), (textBox4.Text));
MailAddress to = new MailAddress((textBox3.Text), (textBox4.Text));
SmtpClient smtp = new SmtpClient()
{
Host = (textBox6.Text),
Port = 587,
EnableSsl =
true,
DeliveryMethod =
SmtpDeliveryMethod.Network,
UseDefaultCredentials =
false,
Credentials =
new NetworkCredential(from.Address, (textBox5.Text))
};
using (MailMessage mess = new MailMessage(from, to)
{
Subject = (textBox4.Text),
Body = (textBox1.Text)
})
{
smtp.Send(mess);
}
<Code>
c# run in background
Started by Delta22, Feb 18 2013 06:47 AM
1 reply to this topic
#1
Posted 18 February 2013 - 06:47 AM
Programmer(in training), hacker(in minimal training), good with computers and mature, all you need to know about me but feel free to talk to me, contact me or whatever, i am no danger.
#2 Guest_ElatedOwl_*
Posted 18 February 2013 - 08:25 AM
Just fyi you don't need the parenthesis around textBox#.text.
You either need to use the SmtpClient.SendAsync method rather than .Send (which is the easier of the two) or you need to do your work in a separate thread.
Here's the docs for SendAsync.
You either need to use the SmtpClient.SendAsync method rather than .Send (which is the easier of the two) or you need to do your work in a separate thread.
Here's the docs for SendAsync.