Click here to Skip to main content
16,011,870 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
how i can send mails to any user
like
gmail,hotmail,siffy,yahoo,rediff and other servers.

in c#.net window application
Posted

\\you can try the following code


using System.Net.Mail;
using System.Net;

string From = "abc@gmail.com";\\your email id
string Password = "abc";\\ your password
string To = "def@xyz.com";\\email id on which mail is to be sent
MailMessage msg = new MailMessage();
SmtpClient client = new SmtpClient();
client.Port = 587;\\ write the port no for example if your email id is from gmail then your port will be 587
client.Host = "smtp.gmail.com";\\write smtp name of your email id
client.EnableSsl = true;\\ write ssl of your Id
client.Timeout = 50000000;
client.Credentials = new NetworkCredential(From, Password);
msg.From = new MailAddress(From,"");
msg.Subject = "Test Mail";\\ write Subject Of Your Email
msg.Body = "12626";\\ contents you want to mail
client.Send(msg);
MessageBox.show("Mail Successfully Sent !!!");


\\ smtp name and port no can easily be searched on google
like for example if your email id is configured from gmail

then gmail uses smtp name as "smtp.gmail.com" its outgoing port no "587"/"25"
and SSl has to kept true
 
Share this answer
 
The target email server is irrelevant.

Work through these links ... http://www.codeproject.com/search.aspx?q=c%23+send+email[^]

Google has many more
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900