a kkk

a kkk

  • NA
  • 1
  • 0

Having problem with send email code Please help

Jul 3 2009 5:00 PM

Hello experts,

I'm new to C# and trying to write an email program. I want to send email on button_click event.  Now I get two error messages.

1.       'using System.Web.Mail;'

Error: The type or namespace name 'Mail' does not exist in the namespace 'System.Web' (you are missing an assembly reference?)

I can understand that 'Mail' method is not a part of 'System Web' but I need 'Mail' in order to use MailMessage class. Also this exact same error message shows up on the following line.

MailMessage mail = new MailMessage();

 

Can please somebody show me how to make it working?

 

Thanks a lot in advance

 

For reference here is my code.
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
System.Web.Mail;
 
 

namespace
WindowsFormsApplication1
{
public partial class Openticket : Form
{
public Openticket()
{
InitializeComponent();
}
 
private void btsend_Click(object sender, EventArgs e)
{
MailMessage mail =
new MailMessage();
mail.To =
"[email protected]";
mail.From = txtuserid.Text;
mail.Subject = txtsubject.Text;
mail.Body = rtbmessage.Text;
SmtpMail.SmtpServer =
"localhost";
SmtpMail.Send(mail);
 
}
 
}
}


Answers (1)