Click here to Skip to main content
15,897,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have code for mail sending as below.But here i need to give both userid and password of sender.how to give without password of sender.emailid only in C#.

C#
MailMessage mm = new MailMessage("vino@gmail.com", txtEmailSubscribe.Text.Trim().ToString());
                       mm.Subject = "Welcome to codeproject.com";

                       mm.Body = "Name: " + "Hi" + "<br /><br />Email: " + txtEmailSubscribe.Text.Trim().ToString() + "<br />" + "Success" + "<br/>ForMoreDetails:" + "http://www.codeprojectcom";
                       mm.IsBodyHtml = true;
                       SmtpClient smtp = new SmtpClient();
                       smtp.Host = "smtp.gmail.com";
                       smtp.EnableSsl = true;
                       System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
                       NetworkCred.UserName = "vino@gmail.com";
                       NetworkCred.Password = "54645645";
                       smtp.UseDefaultCredentials = true;
                       smtp.Credentials = NetworkCred;
                       smtp.Port = 587;
                       smtp.Send(mm);
Posted
Updated 7-Oct-13 18:32pm
v2

For sending mails from server without username & password you have to make sure that SMTP Service is installed & running on Server. Given below the code for sending mail from SMTP -
C#
SmtpClient smtp = new SmtpClient();
smtp.Host = "LOCALHOST"; /// OR MACHINE NAME
smtp.Port = 25; /// OR 2525 IN SOME SYSTEMS
smtp.Send(mm);
 
Share this answer
 
Comments
itsureshuk 9-Oct-13 9:57am    
in online hosting how to give with out password.
Hi...
See this link, its may helpful to u.
How I can track Email send or Not Through Asp .Net?[^]
Thank u.
 
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