Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot get single new line \n
    primarykey
    data
    text
    <p>I'm trying to create 2 lists of items in an email body by passing in a string upon creation. One of the lists works perfectly with no problems (I.E. each entry is on a new line, just as intended), but I cannot figure out how to get the other list formatted in the same way. It's either no new lines, or double line spacing. I've tried the System.environment.newline, "\r\n", '\n', "\n", etc. When I set a breakpoint in the code, the string has the '\n' in the appropriate places, but it's not showing up when the email is created. Any tips?</p> <pre><code>string users = ""; for (int i = 0; i &lt; disabledUsers.Count; i++) { users += disabledUsers[i] + "\n"; //This does not show up as a new line for each item in an email } // initializing users with expired passwords to a string format string expiredUserPasswords = ""; for (int i = 0; i &lt; expiredPassword.Count; i++) { expiredUserPasswords += expiredPassword[i] + "\n"; //this works perfectly } // creating admin message MailMessage emailAdmin = new MailMessage(); emailAdmin.From = new MailAddress("email.email@email.com"); emailAdmin.Body = "Automated system message:\n\nThe following " + numExpiredPasswords + " accounts have expired passwords and have been disabled:\n\n" + expiredUserPasswords + "\n\nThe following " + numDisabledAccounts + " accounts have been disabled for 90+ days:\n\n" + users + "\n\nThere are " + activeNum + " active users, " + numDisabled + " disabled users, and " + totalNum + " total users.\n\nThis is an automatically generated email. Please do not reply."; emailAdmin.Subject = "Dataroom cleanup log"; </code></pre> <p>I can't see ahy difference between these two lists and why one works fine while the other one won't. Any help would be appreciated!</p> <p>Edit - I figured it out. Thanks to Microbloft, Outlook automatically removes what it thinks are excessive newline commands. I fixed it by just adding a period right before the newline, so ".\n".</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload