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

  • SEARCH
  • Home
  • 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 552879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:32:47+00:00 2026-05-13T11:32:47+00:00

I have a static helper method that I wrap around SMTPClient to send email.

  • 0

I have a static helper method that I wrap around SMTPClient to send email.

I am storing the SMTP authentication in the web.config -> in the default location that System.Net namespace objects look for.

I am passing the credentials to the SMTPClient, because I want to run my password decryption on the password before the SMTPClient uses this.

The issue that I’m encountering here is – when I run this once, the password is stored somehwere as “decrypted” somehow in the cache. When I try and run this method a second time in the same session, I get an error, because it’s trying to decrypt a password that was already decrypte the first time it was ran. Any ideas?

    public static void SendEmail(MailMessage mailMessage)
    {
        SmtpClient smtpClient = new SmtpClient();
        NetworkCredential nc = new NetworkCredential();
        nc = (NetworkCredential)smtpClient.Credentials;
        nc.Password = Tools.Decrypt(nc.Password);
        smtpClient.Credentials = nc;
        smtpClient.Send(mailMessage);
        nc = null;
        smtpClient.Credentials = null;
     }
  • 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-13T11:32:48+00:00Added an answer on May 13, 2026 at 11:32 am

    As NetworkCredentials is a class you are passing a reference of to your nc variable this means when you decrypt the password you are decrypting it on the original object.

    You either need to clone the object or only do this once when your application starts.

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

Sidebar

Related Questions

I have an object obj that is passed into a helper method. public static
I currently have a helper class that I am using to obfuscate a static
I have written an ASP.NET HttpModule and I have a static helper class that
Lets say I have a method that looks like this: public static String[] parseFoo(Foo
I have the following helper method: public static T CreateRequest<T>() where T : Request,
I would like to create a static helper method that I can call from
I have a Static helper class implemented that helps cache and retreive some read-only,
I have a Helper method that I need to use across multiple views. In
I have the following helper method that returns the value from a field. public
I have a helper method that takes a begin date and an end date

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.