Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:19:03+00:00 2026-06-17T17:19:03+00:00

Possible Duplicate: send email asp.net c# I have sent mail several times using the

  • 0

Possible Duplicate:
send email asp.net c#

I have sent mail several times using the technique several times before but somehow it doesnt work i am providing the code in the following:

MailMessage myMailMessage = new MailMessage();
            myMailMessage.Subject = "Response From Client";
            myMailMessage.Body = "hello word";
            myMailMessage.From = new MailAddress("mymail@gmail.com", "jub");
            myMailMessage.To.Add(new MailAddress("mymail@gmail.com", "Softden"));

            SmtpClient mySmtpClient = new SmtpClient();
            mySmtpClient.Send(myMailMessage);

and my web.config is:

<mailSettings>
      <smtp deliveryMethod = "Network" from="Jubair &lt;mymail@gmail.com&gt;">
        <network defaultCredentials="false" enableSsl="true" userName="mymail@gmail.com" password="Mypassword" host="smtp.gmail.com" port="587"></network>
      </smtp>
    </mailSettings>

it says the smtp server requires a secure connection or the client was not authenticated.. Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:19:05+00:00Added an answer on June 17, 2026 at 5:19 pm

    Try adding something like this
    Per Dominic’s answer on Stackoverflow look at he following example

    using System.Net;
    using System.Net.Mail;
    
    var fromAddress = new MailAddress("from@gmail.com", "From Name");
    var toAddress = new MailAddress("to@example.com", "To Name");
    const string fromPassword = "fromPassword";
    const string subject = "Subject";
    const string body = "Body";
    
    var smtp = new SmtpClient
               {
                   Host = "smtp.gmail.com",
                   Port = 587,
                   EnableSsl = true,
                   DeliveryMethod = SmtpDeliveryMethod.Network,
                   //UseDefaultCredentials = false,
                   Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
               };
    using (var message = new MailMessage(fromAddress, toAddress)
                         {
                             Subject = subject,
                             Body = body
                         })
    {
        smtp.Send(message);
    }
    

    //—————– A simple approach below —————
    I just tested this below and it works

    var mail = new MailMessage();

    // Set the to and from addresses.
    // The from address must be your GMail account
    mail.From = new MailAddress("noreplyXYZ@gmail.com");
    mail.To.Add(new MailAddress(to));
    
    // Define the message
    mail.Subject = subject;
    mail.IsBodyHtml = isHtml;
    mail.Body = message;
    
    // Create a new Smpt Client using Google's servers
    var mailclient = new SmtpClient();
    mailclient.Host = "smtp.gmail.com";//ForGmail
    mailclient.Port = 587; //ForGmail
    
    
    // This is the critical part, you must enable SSL
    mailclient.EnableSsl = true;//ForGmail
    //mailclient.EnableSsl = false;
    mailclient.UseDefaultCredentials = true;
    
    // Specify your authentication details
    mailclient.Credentials = new System.Net.NetworkCredential("fromAddress@gmail.com", "xxxx123");//ForGmail
    mailclient.Send(mail);
    mailclient.Dispose();
    

    //The .config settings there are two options on how you could set this up I am suspecting that this is the issue you are having

    <system.net>
        <mailSettings>
          <smtp from="from@gmail.com" deliveryMethod="Network">
            <network userName="from@gmail.com" password="mypassword" host="smtp.gmail.com" port="587"/>
          </smtp>             
        </mailSettings>
      </system.net>
    

    or option 2

    <configuration>
        <appSettings>
            <add key="smtpClientHost" value="mail.localhost.com"/> //SMTP Client host name
            <add key="portNumber" value="587"/>
            <add key="fromAddress" value="yourEmailAddress@gmail.com"/>
        </appSettings>
    </configuration>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Send email using System.Net.Mail through gmail. (C#) I am using this code
Possible Duplicates: ASP.NET- Sending an e-mail how to send mail using C#? How can
Possible Duplicate: send html email via C# ASP.NET Can anyone provide me with sample
Possible Duplicate: Unable to send an email to multiple addresses/recipients using C# I have
Possible Duplicate: Sending email in .NET through Gmail I am trying to send a
Possible Duplicate: Sending HTML email from PHP I need to send an html mail
Possible Duplicate: Sending mass email using PHP I have a PHP script that sends
Possible Duplicate: Sending email in .NET through Gmail Say I want to send an
Possible Duplicate: Sending email in .NET through Gmail I want to send an email
Possible Duplicate: Sending HTML email from PHP Using PHP to send an email. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.