The type or namespace name 'Mail' does not exist in the namespace'System.Web'


S

sravan_reddy001

i'm trying to write a win app to send a mail...

but the error message saying "Mail" doesn't exist in Web Name space..
( .net framework 2.0 used)



Error 1 The type or namespace name 'Mail' does not exist in the
namespace 'System.Web' (are you missing an assembly reference?) F:
\VS.net\Holidays\MailApplication\MailApplication\Form1.cs 8 18
MailApplication


this is the code....



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Web.Mail;

namespace MailApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = textBox1.Text;
mail.From = textBox2.Text;
mail.Subject = textBox3.Text;
mail.Body = textBox4.Text;
mail.SendMail();
SmtpMail.SmptServer = "localhost";
SmtpMail.SendMail(mail);
}
}
}
 
Ad

Advertisements

A

Arne Vajhøj

sravan_reddy001 said:
i'm trying to write a win app to send a mail...

but the error message saying "Mail" doesn't exist in Web Name space..
( .net framework 2.0 used)

Error 1 The type or namespace name 'Mail' does not exist in the
namespace 'System.Web' (are you missing an assembly reference?) F:
\VS.net\Holidays\MailApplication\MailApplication\Form1.cs 8 18
MailApplication
using System.Web;
using System.Web.Mail;

Do you have a ref to System.Web.dll ?

Arne

PS: Are you aware that it is obsolete and you should
be using System.Net.Mail ?
 
Ad

Advertisements

D

Duggi

i'm trying to write a win app to send a mail...

but the error message saying "Mail"  doesn't exist in Web Name space..
( .net framework 2.0 used)

Error   1       The type or namespace name 'Mail' does not exist in the
namespace 'System.Web' (are you missing an assembly reference?) F:
\VS.net\Holidays\MailApplication\MailApplication\Form1.cs       8       18
MailApplication

this is the code....

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Web.Mail;

namespace MailApplication
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MailMessage mail = new MailMessage();
            mail.To = textBox1.Text;
            mail.From = textBox2.Text;
            mail.Subject = textBox3.Text;
            mail.Body = textBox4.Text;
            mail.SendMail();
            SmtpMail.SmptServer = "localhost";
            SmtpMail.SendMail(mail);
        }
    }

}

use system.Net.Mail ...

MailMessage mailMsg = new MailMessage();
mailMsg.To.Add(args[1]);

// From
MailAddress mailAddress = new MailAddress(args[0]);
mailMsg.From = mailAddress;

// Subject and Body
mailMsg.Subject = args[2];
mailMsg.Body = args[3];

// Init SmtpClient and send
SmtpClient smtpClient = new SmtpClient(args[4],
Convert.ToInt32(args[5]));
System.Net.NetworkCredential credentials = new
System.Net.NetworkCredential(args[5], args[5]);
smtpClient.Credentials = credentials;

smtpClient.Send(mailMsg);
}
catch (Exception ex)
{
Console.WriteLine( ex.Message );
}

hope this would work for you...
 

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

Top