views:

85

answers:

3

Hi,

In C#, I'm sending a mail with an activation link to users after they have registered. However, the link is split over two lines in the mail and thus doesn't work.

I've checked in Visual Studio and the string containing the link looks fine. I've also tried: strMessage.Replace("\r", ""); strMessage.Replace("\n", ""); but without success.

Do you have any ideas on how to solve this? I've googled it for hours and can't find the solution...

Thanks! /J

A: 

Is the link longer than 78 chars? Or is there some other text in front of it?

If so, see if you can make it less than 78 and I don't think it'll wrap it. Otherwise, I seem to remember that this could be sort of fixed in some email applications by changing the encoding, possibly the same might work here since I see that there are various Encoding properties of MailMessage.

ho1
I made the link shorter than 78 chars, just to see if that made it stay on one line, but to no success. It still broke on the same place...
Joran
A: 

If you are sending the message as an HTML email, then you could put a link around the email so that it renders on one line, and then have the actual link in brackets with instructions on how to copy and paste it ensuring it's on one line.

Register <a href="http://www.longaddresshere.com/thatkeepswrapping"&gt;here&lt;/a&gt;
(if the above does not appear in a link, copy the following link into your
browser ensuring that it all goes on one line: 
http://www.longaddresshere.com/thatkeepswrapping)
Matthew Steeples
Yes, the message is in HTML. The entire mail is in one long string, which looks fine in Outlook and the webmail interface I'm using. I'm not sure I understand what you mean with the link around the e-mail. Plus I can't get the 'Register' command to work. Could you explain further?Thanks!
Joran
I doubt this is the reason for it, but does it make a difference if you use double quotes rather than single quotes?eg strMessage += "<a href=\"" + ........ + "\">My Account</a>The \ means that the compiler will use put a " into the string rather than terminate it
Matthew Steeples
Didn't make any difference, still no luck. :(
Joran
When i put the link last in the mail message, outside the table tags, it worked. Even stranger?!
Joran
A: 

I finally managed to solve this annoying problem. It seems like Outlook was the cause of everything, it divided my LONG html string into two lines. My link just happened to be right at the point of the line break. So I added the sufficient number of characters (with the same color as the background) to make my link start on the second line.

Not the best solution, but it worked in this case...

Joran