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 711317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:43:18+00:00 2026-05-14T04:43:18+00:00

sHi folk, I’ve been storing SQL connection strings in web.conf which is fine but

  • 0

sHi folk,

I’ve been storing SQL connection strings in web.conf which is fine but now I need to store SMTP credentials somewhere protected. web.conf seems like the likeliest place since its protected but how can they be stored?

I’ve added the details to my web.conf but amnot sure how to reference them

<system.net>
   <mailSettings>
   <smtp>
    <network 
      host ="server"
      userName ="username"
      password ="password"
      defaultCredentials =" false"
      port =" 25"
    />
  </smtp>
  </mailSettings>
</system.net>

Sending the mail:

      Dim mail As New MailMessage()

        'set the addresses
        mail.From = New MailAddress("billy.jones@networkroi.co.uk")
        mail.To.Add(ToAddress)

        'set the content
        mail.Subject = "User Request Submitted via Client Portal"
        mail.Body = "text in here"
        mail.IsBodyHtml = True

        ' authenticatin
        Dim basicAuthenticationInfo As New System.Net.NetworkCredential("username", "-password-")


        'send the message
        Dim smtp As New SmtpClient("servername")
        smtp.UseDefaultCredentials = False
        smtp.Credentials = basicAuthenticationInfo

        smtp.Send(mail)

— Jonesy

  • 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-05-14T04:43:18+00:00Added an answer on May 14, 2026 at 4:43 am

    You can take a few approaches. Each has its merits.

    • If you want the server credentials to be configurable, you should store them in a database table.
    • If you think they will be fairly static, but you don’t want to have to recompile code to change them, use web.config (or app.config when applicable).
    • You could also look into registry if you want them to be configurable from server to server.

    In case you were asking specifically how to store SMTP credentials in a web.config file, you could do something like this :

    <configuration>
       <appSettings>
          <add key="SMTP_Server" value="my.smtpserver.com" />
          <add key="SMTP_Username" value="myusername" />
          <add key="SMTP_Password" value="mypassword" />
       </appSettings>
    </configuration>
    

    If you need help getting values out of appSettings, check out this article.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.