The specified string is not in the form required for a subject

At one of my "Playground" sites,, I get an approval email every time somebody submits a blog or website to the directory. ( If you have any kind of  blog or website related to blogging I encourage you to submit it there).  All submissions go into the database, but they are marked as "Active=0" until such time as i review the submission via a link to a special "Admin" page that I get in the email. It only takes me a second to inspect a site that represents a  legitimate submission (e.g., not porn, not drugs, no redirects, no funny business script kiddie bullshit, etc.) and put the form into edit mode, mark the "Active" checkbox, and update the record which makes it activated into the directory immediately.

However, you always get the occasional bot or bullshit artist that wants to try and see if they can pull a fast one, and they submit junk in the hopes that my directory isn't smart enough to stop them. Invariably, the subject line of the email I get, which includes their submitted site title, has B.S. in it. The result may be that the System.Net.Mail namespace throws an exception, and usually the culprit is the subject line as mentioned in the title of this post.

Here is an easy fix:

subject= Regex.Replace(subject, @"[^ -~]", "");


  1. Anonymous3:45 PM

    I'm trying to use the Password Recovery control to send forgotten passwords. So far, trying to use this control

    has been such a joke for such an easy task, even after properly configuring SMTP via the Web Admin Tool!

    I've tried using the encryption option as well in the membership provider only to receive the esoteric Autogen,

    Machine Key, blah, blah, blah, error!

    What's the crack Microsoft?

  2. I don't know what your problem is, but it isn't related to the subject of this post. You definitely do not have your SMTP settings complete or correct.


Post a Comment

Popular posts from this blog

ASP.NET: Loss of Session / Cookies with Frames

FIREFOX / IE Word-Wrap, Word-Break, TABLES FIX