Trying to send an email

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top