L
Lars
Hi
I'm trying to send an email using the following code in an ASP.NET 2.0 form.
Can some one tell me why the email doesn\t arrive at the destination and wy
the form tries to update but never finishes updating. THe progress bar in
IEs status bar never finish. There's no exception or any thing.
Here's the code.
protected void pbSendEmail_Click(object sender, EventArgs e)
{
MailMessage Msg = new MailMessage();
NameValueCollection Headers = new NameValueCollection();
MailAddress Address = new MailAddress(tbEmail.Text);
MailAddress ReplyTo = new MailAddress(tbEmail.Text);
SmtpClient MC = new SmtpClient();
Headers.Set("Header", "aHeader");
Headers.Set("Footer", "aFooter");
Headers.Set("From", tbEmail.Text);
Headers.Set("Sender", tbEmail.Text);
Headers.Set("Message", "aMessage");
Headers.Set("Body", tbMessage.Text);
Msg.Body = tbMessage.Text;
Msg.Headers.Add(Headers);
Msg.To.Add("(e-mail address removed)");
Msg.From = Address;
Msg.ReplyTo = ReplyTo;
Msg.Bcc.Add("(e-mail address removed)");
MC.Host = "mailout.telia.com";
MC.Port = 25;
try
{
MC.Send(Msg);
}
catch(Exception ex)
{
tbMessage.Text = tbMessage.Text + "\n\n\n\nError Sending
message\n\n" + ex.Message;
}
}
Lars
I'm trying to send an email using the following code in an ASP.NET 2.0 form.
Can some one tell me why the email doesn\t arrive at the destination and wy
the form tries to update but never finishes updating. THe progress bar in
IEs status bar never finish. There's no exception or any thing.
Here's the code.
protected void pbSendEmail_Click(object sender, EventArgs e)
{
MailMessage Msg = new MailMessage();
NameValueCollection Headers = new NameValueCollection();
MailAddress Address = new MailAddress(tbEmail.Text);
MailAddress ReplyTo = new MailAddress(tbEmail.Text);
SmtpClient MC = new SmtpClient();
Headers.Set("Header", "aHeader");
Headers.Set("Footer", "aFooter");
Headers.Set("From", tbEmail.Text);
Headers.Set("Sender", tbEmail.Text);
Headers.Set("Message", "aMessage");
Headers.Set("Body", tbMessage.Text);
Msg.Body = tbMessage.Text;
Msg.Headers.Add(Headers);
Msg.To.Add("(e-mail address removed)");
Msg.From = Address;
Msg.ReplyTo = ReplyTo;
Msg.Bcc.Add("(e-mail address removed)");
MC.Host = "mailout.telia.com";
MC.Port = 25;
try
{
MC.Send(Msg);
}
catch(Exception ex)
{
tbMessage.Text = tbMessage.Text + "\n\n\n\nError Sending
message\n\n" + ex.Message;
}
}
Lars