Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
Can you give me solutions for how to send email in asp.net without using password in asp.net c#.
Please give me

What I have tried:

string to = "adhikar.patil@gmail.com";
            string from = "adhikar.patil@gmail.com";
            MailMessage message = new MailMessage(from, to);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("<table>");
            sb.AppendFormat("<tr><td>Name:</td><td>{0}</td></tr>", txtName.Text.Trim());
            sb.AppendFormat("<tr><td>Email:</td><td>{0}</td></tr>", txtEmail.Text.Trim());
            sb.AppendFormat("<tr><td>Phone No</td><td>{0}</td></tr>", txtPhoneNo.Text.Trim());
            sb.AppendFormat("<tr><td>Organisation:</td><td>{0}</td></tr>", txtOrganisation.Text.Trim());          
            sb.Append("<table>");
           
            message.Subject = "BDS Contacted by " + txtName.Text;
            message.Body = sb.ToString();
            //message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml = true;
            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            System.Net.NetworkCredential basicCredential1 = new
            System.Net.NetworkCredential("abc@gmail.com", "abc");
            client.EnableSsl = true;
            client.UseDefaultCredentials = false;
            client.Credentials = basicCredential1;
            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
Posted
Updated 29-Oct-18 1:06am

Basically, you can't, unless your email service is configured to not need one - and that's is incredibly rare. Most systems are set up to require a password (which may only have to be entered to your reader / writer app once) before they will send an email for security: to prevent me pretending to be you; and to prevent spammers and phishers from using your account via rogue or trojan apps.

Check with your email service, and see what they say - if they don't permit it, then you can't do it.
 
Share this answer
 
Use the SMTP server provided by your web host.

Things you shouldn't spend time doing - Sending email via Gmail[^]
 
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