Solved

c# winform send mail

Posted on 2008-10-31
7
2,464 Views
Last Modified: 2013-12-17
Hi,
I am working on windowsform application. Finally this application would be installed on clients machine.
I have to integrate mail module in my application.

How can it be done. What namespaces should i import in C# . Any example.

Should the client machine have smtp server installed
0
Comment
Question by:dotnet0824
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 13

Accepted Solution

by:
SameerJagdale earned 150 total points
ID: 22848269
In order to send email in C# code, do the following:
 

// create mail message object
MailMessage mail = new MailMessage();
mail.From = "";           // put the from address here
mail.To = "";             // put to address here
mail.Subject = "";        // put subject here	
mail.Body = "";           // put body of email here
SmtpMail.SmtpServer = ""; // put smtp server you will use here 
// and then send the mail
SmtpMail.Send(mail);

Open in new window

0
 
LVL 8

Assisted Solution

by:rpkhare
rpkhare earned 100 total points
ID: 22848273
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22848277
0
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 

Author Comment

by:dotnet0824
ID: 22848305
Is there any Inbuilt methods in .NET I can use???? What imports statement should i use

MailMessage mail = new MailMessage();  (Is this 3rd party) I cant find it in .NET
0
 
LVL 5

Assisted Solution

by:rendaduiyan
rendaduiyan earned 75 total points
ID: 22848376
using System.Net.Mail;

       
MailAddress from = new MailAddress("xxxi@xxx.com", "xxxx");
        MailAddress to = new MailAddress("xxx@xxx.com", "xxx");
        MailMessage mail = new MailMessage(from, to);  
        foreach(ListItem li in this.DropDownList2.Items)
        {
            MailAddress one = new MailAddress (li.Text);
            if(one.User != "xxx")
            {
                mail.To.Add(one);
            }
        }
        
        mail.Subject = "books status updated";
        mail.Priority = MailPriority.Normal;
        mail.IsBodyHtml = false;
        mail.Body = "this mail is sent by " + Server.MachineName
            + " automatically. Please go to http:/xxx for details." 
            + Environment.NewLine
            + this.TextArea1.Value;
        SmtpClient client = new SmtpClient("sgp-sg-mb01.sgp.agilent.com");
        client.Credentials = CredentialCache.DefaultNetworkCredentials;
        client.Send(mail);

Open in new window

0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22849426
it's in .net
make sure you import the namespace,
Imports System.Net.Mail
 
0
 
LVL 9

Assisted Solution

by:gdupadhyay
gdupadhyay earned 75 total points
ID: 22850633
I already give a answer of this question, but for different expert.

You can find out accepted solution on:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_23688815.html
Please let me know, if you have any question.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question