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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:09:15+00:00 2026-06-11T11:09:15+00:00

Scenario Around 20 ASP.net(VB) applications share the same code framework and when deployed also

  • 0

Scenario

Around 20 ASP.net(VB) applications share the same code framework and when deployed also shares a common web.config. Throughout the various applications we use System.Net.Mail.SmtpClient/MailMessage to send e-mails and now we would like to implement an e-mail opt-out feature for our users with a minimal amount of change to the existing code. That leaves out the simplest approach; inheriting a class from SmtpClient, say OurSmtpClient, and override the Send() method to remove all users that have opted to not receive e-mails, as that would mean we would have to change all New SmtpClient() to New OurSmtpClient() throughout the apps.

Alternatives

We’ve previously used tagMapping to remap tags to our in-house, derived alternatives, are there anything similar for classes so that all SmtpClient automatically becomes OurSmtpClient and thus will use the overridden Send() method?

We’ve also looked at Extensions, but the problem here is that we can’t override existing methods, only add new ones?

Next alternative we have considered is reflection, but we couldn’t get our minds around on how to actually implement it.

Events .. Oh, if there was a Sending event …

Code (cause everyone likes it)

Here is the inherit approach, just to understand what we are looking for:

Public Class OurSmtpClient
    Inherits SmtpClient

    Public Overloads Sub Send(message As MailMessage)
        For i As Integer = message.To.Count - 1 To 0 Step -1
            With message.To(i)
                If (.Address.Contains("test")) Then
                    message.To.RemoveAt(i)
                End If
            End With
        Next

        MyBase.Send(message)
    End Sub
End Class

Any suggestions? How can this be done without changing the code in the existing applications and only in the shared code (lives in App_Code in the apps) or the shared web.config?

  • 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-11T11:09:17+00:00Added an answer on June 11, 2026 at 11:09 am

    The fact that you are struggling to implement what should be a straightforward requirement is a big clue that you’ve built up too much technical debt. Your post conveys a strong reluctance to pay down technical debt. This is something that you must avoid and instead embrace Merciless Refactoring. Bite the bullet and introduce that specialised SMTP class.

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

Sidebar

Related Questions

Consider the scenario of upgrading an ASP.NET MVC project. This question is around up-converting
I have an ASP.NET app, very basic, but right now too much code to
Using ASP.NET Entity Framework, how can I change the Foreign Key association between two
The scenario is around calling an external SSL SOAP web service from within Mirth.
I have started converting my simple website to ASP.NET MVC, just to mess around
And what would you recommend for an ASP Net web application, with a not
I found this scenario quite common but looking around nothing helped. I'm not really
I am working on a asp.net web application that has is a part of
I recently played around with the ASP.NET WebAPI, including some Html-Pages displaying results, trying
This goes around the delightful scenario in which Entity Framework refuses to allow the

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.