Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 75 Time: 11:38 - Mar 04, 2009  

dustPuppy

sending an email in .net: the specified string is not in the form required for a subject?

I'm getting this error when trying to send out an email with .net 2.0:

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

Do you know what could be wrong?

Categories

Answer Discussion
Tutorials

 

rcastagna

Date:: Mar 05, 2009

Time:: 00:05

Could you please post a snip of the code you're using, especially the string your wanting to use for the subject as well as the construction of you mail message object?

It would make it much easier to assist you.

Thanks!
Ric

dustPuppy

Date:: Mar 05, 2009

Time:: 04:52

The problem is that it's running through a range of different emails it sends and right now I haven't debugged to the point where i found out which one is giving the error.
I was just a bit surprised, since I didn't know there were characters that could trigger this for an email subject.

rcastagna

Date:: Mar 05, 2009

Time:: 07:24

Oh, yeah, dust...there's ways that automatic stuff can get fubar'd.

Let's say you're getting the subject line from the database and you run into a NULL value. Well, if they're not converted to string.Empty or "" then you could potentially see the error you're describing.

Here's another scenario - your database holds something like 'Dwayne "The Rock" Johnson' for the value. Completely valid data, but those additional quotes within the value would inadvertently terminate the current string right after 'Dwayne ' and starting with 'The' you would have an unrecognized value.

I'm sure there are a few other reasons why this could happen, but those are a couple I've run across myself - especially with "blind" systems where people could register for a forum, or a subscription-based site.

Sadly, it's hard to prepare for the varying levels of stoooopid that the ordinary user can introduce into a perfectly good system. :)

I hope you're doing well - it's been quite a while since I've had time to spend on Quomon, but I'm glad to see it's thriving!

Let me know if I can help you out any further...I'd be happy to!

Take care,
Ric

dustPuppy

Date:: Mar 05, 2009

Time:: 12:53

Thanks, Ric, I'm doing good and it's good to see you here again and always a pleasure to read your responses.
I figured out what the issue was, by doing what they recommend here: http://blog.dotsmart.net/2008/02/15/syst...
message.Subject = subject.Replace('\r', ' ').Replace('\n', ' ');

I don't know how that carriage-return got in the subject, but this solved it :)
I'll give you some points for getting me in the right direction and pointing out some other things that i wasn't taking into account either.

Question Answered

This question has been closed, and points have been rewarded to the following experts:


rcastagna: 30
dustPuppy: 45

You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No tutorials have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10279

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es