sending email using c# Windows application

  • Thread starter rohan_from_mars
  • Start date
R

rohan_from_mars

I want a Windows C# application to allow users to send email. It is a
windows application and not ASP.NET web application. So how do i do it?

I know that ASP.NET allows to use SMTPMail class of System.Web.Mail
namespace but that is not allowed in the C# Windows Application. So
please tell me how do it asap.
 
S

Steven Nagy

Why do you think it is not allowed?
Have you tried adding a reference to System.Web ?
I don't know of any other way to send mail sorry.
 
R

rohan_from_mars

the thing is C# Windows Application is not supporting System.Web.Mail
namespace. I did try adding the reference by the syntax:
using System.Web.Mail but it gave compiler error due to the same
reason.
 
S

Steven Nagy

Thats not how you add a reference.
You need to go to your reference list in your solution file and right
click on "References" and choose "Add Reference". Under the .NET tab,
choose System.Web.dll and add it to your project.

You can not use "Using" on a namespace if it has not been referenced.

Try that first and see how you go.
 
R

rohan_from_mars

Thanx buddy!! Your solution worked.
I was not knowing the concept of adding reference
 
S

Steven Nagy

rohan_from_mars said:
Thanx buddy!! Your solution worked.
I was not knowing the concept of adding reference

No worries buddy!
When you create a new solution in Visual Studio, it assumes you want to
use some DLL's by default. For example, in a Windows App, it assumes
you will want to use System.Windows.Forms.dll so it adds a reference
for you by default. In the reference list you can see which ones were
already there.

You can add references to any .NET assembly, such as System.web,
System.XML, 3rd party components like Infragistics UI library, or even
your own projects (if, for example, you add a second project to your
solution of type "class library"). You can also add COM references to
older components that aren't written in .NET.

The "Using" statement that you were using only tells the code in the
current file that you don't need to use the full type name. For
example, if I want to connect to a SQL Server database, I have to write
code like this:

System.Data.SqlClient.SqlConnection dbc =
new System.Data.SqlClient.SqlConnection(CONNECTION_STRING);

But if you add the following code:
using System.Data.SqlClient;

... then you can shorten what you write to:
SqlConnection dbc = new SqlConnection(CONNECTION_STRING);
 

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