Solved

c# winform send mail

Posted on 2008-10-31
7
2,459 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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