Solved

c# winform send mail

Posted on 2008-10-31
7
2,448 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
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now