0
votes

I've got an application that sends nicely formatted processing logs to the user.

When I run the application locally (debug mode), using [SMTPServer] to send, the logs arrive neatly formatted and look as I'd expect.

When I install the application on a testing server and configure it to use the same [SMTPServer] to send, the logs arrive in my Inbox with the line breaks removed.

Converting to HTML format is not really an option right now.

I realize that Outlook strips them, but I'm confused as to why it does it only when coming from the server.

Thoughts?

4
are you running a different version of IIS on your testing server? - Russ Bradberry
No IIS...it's a Windows Service. - Adam Poirier

4 Answers

2
votes

I'm not sure this would fix it, but try to add a line break by either using:

System.Environment.NewLine

or simply "\n". The former is better practice, though.

1
votes

What code is it that introduces the line breaks? If the code for sending the mails is identical, and it is sent through the same server and consumed by the same client, I would investigate the source; the logs themselves. Can they look different when produced on the server, compared to how they come out when the system is run locally?

1
votes

Try writing the log information out to a file on both boxes to see if there is a difference in the output. If they are the same then the problem is likely in the configuration of the mail server, possibly with the default email encoding or something like that. If they are different then you can setup remote debugging to the server to inspect the string/email as you build it to see if you can find the variant.

I have never seen a different line terminator between Vista and 2003 (in default configurations), but I agree it is something to look at...

0
votes

In the email world, lines can only be terminated with "\r\n" (vbCrLf). Using Environment.NewLine or "\n" or "\r" is incorrect, and can lead to problems.

New lines must be terminated with the combination of "\r\n" (without quotes).

I don't know if that is the problem here, however, if you are building an email using StringBuilder, the correct way to do this is:

sb.Append( singleLineContent);
sb.Append( "\r\n" );