How do I format a String in an email so Outlook wi

2019-01-04 00:10发布

I'm trying to send an email in Java but when I read the body of the email in Outlook, it's gotten rid of all my linebreaks. I'm putting \n at the ends of the lines but is there something special I need to do other than that? The receivers are always going to be using Outlook.

I found a page on microsoft.com that says there's a 'Remove line breaks' "feature" in Outlook so does this mean there's no solution to get around that other than un-checking that setting?

Thanks

27条回答
Rolldiameter
2楼-- · 2019-01-04 00:28

I also had this issue with plain/text mail type.Form Feed \f worked for me.

查看更多
聊天终结者
3楼-- · 2019-01-04 00:29

For Outlook 2010 and later versions, use \t\n rather than using \r\n.

查看更多
ら.Afraid
4楼-- · 2019-01-04 00:30

I've just been fighting with this today. Let's call the behavior of removing the extra line breaks "continuation." A little experimenting finds the following behavior:

  • Every message starts with continuation off.
  • Lines less than 40 characters long do not trigger continuation, but if continuation is on, they will have their line breaks removed.
  • Lines 40 characters or longer turn continuation on. It remains on until an event occurs to turn it off.
  • Lines that end with a period, question mark, exclamation point or colon turn continuation off. (Outlook assumes it's the end of a sentence?)
  • Lines that turn continuation off will start with a line break, but will turn continuation back on if they are longer than 40 characters.
  • Lines that start or end with a tab turn continuation off.
  • Lines that start with 2 or more spaces turn continuation off.
  • Lines that end with 3 or more spaces turn continuation off.

Please note that I tried all of this with Outlook 2007. YMMV.
So if possible, end all bullet items with a sentence-terminating punctuation mark, a tab, or even three spaces.

查看更多
等我变得足够好
5楼-- · 2019-01-04 00:30

Not sure if it was mentioned above but Outlook has a checkbox setting called "Remove extra line breaks in plain text messages" and is checked by default. It is located in a different spot for different versions of Outlook but for 2010 go to the "File" tab. Select "Options => Mail" Scroll down to "Message format" Uncheck the checkbox.

查看更多
Emotional °昔
6楼-- · 2019-01-04 00:31

if the message is text/plain using, \r\n should work; if the message type is text\html, use < p/>

查看更多
爷的心禁止访问
7楼-- · 2019-01-04 00:32

Adding "\t\r\n" ( \t for TAB) instead of "\r\n" worked for me on Outlook 2010 . Note : adding 3 spaces at end of each line also do same thing but that looks like a programming hack!

查看更多
登录 后发表回答