Visual Studio 2008
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using System.Net.Mail;
public partial class FrmSendMail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress(txtGAddress.Text, "Sender's Name");
msg.To.Add(new MailAddress(txtToAddress.Text));
msg.Subject = txtSubject.Text;
msg.Body = txtMessage.Text;
msg.IsBodyHtml = true;
if (fluattachment.HasFile)
{
msg.Attachments.Add(new Attachment(fluattachment.PostedFile.InputStream, fluattachment.FileName));
}
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential(txtGAddress.Text, txtGPassword.Text);
LblReason.Visible = true;
smtp.EnableSsl = true;
try
{
smtp.send(msg);
LblReason.Text = "Mail Sent";
}
catch (Exception ex)
{
LblReason.Text = ex.Message;
}
}
}
Error is
Error 1 'System.Net.Mail.SmtpClient' does not contain a definition for 'send' and no extension method 'send' accepting a first argument of type 'System.Net.Mail.SmtpClient' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\SALMAN\My Documents\Visual Studio 2008\WebSites\Excel1\FrmSendMail.aspx.cs 44 18 C:\...\Excel1\