Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
How to send mail using C#, In personal Domain without gmail smtp?

Help me ASAp

THanks..
Posted
Updated 3-Jul-17 19:13pm
v2
Comments
Kiran Susarla 17-Dec-12 6:32am    
Is the SMTP server enabled for your domain?

C#
SmtpClient client = new SmtpClient("smtp.gmail.com");
NetworkCredential LoginInfo = new NetworkCredential("email@gmail.com", "password");
client.UseDefaultCredentials = false;
client.Credentials = LoginInfo;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("email@gmail.com", "Alert mail");
mail.To.Add(new MailAddress(m.EmailId, "name or .."));
mail.Subject = "Welcome Letter or subject";

mail.Body = "Your message body, you can include html formating";
mail.IsBodyHtml = true;
model.EmailId = model.EmailId;
model.ETo = m.EmailId;
try
{
    client.Send(mail);
    model.IsActive = true;
    Erepo.Add(model);
    Erepo.Save();
}
catch (SmtpException sm)
{
    model.IsActive = false;
    Erepo.Add(model);
    Erepo.Save();
}


If your application is hosted on shared server use localhost instead of smtp.gmail.com
 
Share this answer
 
Comments
ANJYR 17-Dec-12 6:37am    
is necessary use PASSWORD in networkCredential
my client don't want to disclose his password.
nirmalVaishnav 4-Jul-17 1:11am    
yupp, its necessary to add password in network credentials because without adding password you cann't send mail through server.
 
Share this answer
 
yes SMTP is enabled in my domain...
 
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