Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

c# winform send mail

Posted on 2008-10-31
7
Medium Priority
?
2,473 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 600 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 400 total points
ID: 22848273
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22848277
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 

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 300 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 300 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

927 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