Outlook에서 줄 바꿈을 인쇄하도록 이메일에서 문자열의 형식을 어떻게 지정합니까?

StackOverflow https://stackoverflow.com/questions/136052

문제

Java로 이메일을 보내려고 하는데 Outlook에서 이메일 본문을 읽으면 줄 바꿈이 모두 제거되었습니다.줄 끝에 을 넣었는데 그 외에 특별히 해야 할 일이 있나요?수신자는 항상 Outlook을 사용하게 됩니다.

microsoft.com에서 Outlook에 '줄 바꿈 제거' "기능"이 있다고 나와 있는 페이지를 찾았는데, 이는 해당 설정을 선택 취소하는 것 외에는 해결할 방법이 없다는 뜻입니까?

감사해요

도움이 되었습니까?

해결책

사용해야합니다 \r\n 해결책으로.

다른 팁

나는 오늘 이것과 싸우고 있었다. 추가 선 브레이크 "연속"을 제거하는 동작을 부를 봅시다. 약간의 실험은 다음과 같은 동작을 찾습니다.

  • 모든 메시지는 연속으로 시작합니다.
  • 40 자 미만의 라인은 연속을 트리거하지 않지만 연속이 켜져 있으면 라인이 제거됩니다.
  • 40 자 이상 회전 연속이 켜집니다. 이벤트가 꺼질 때까지 계속 켜져 있습니다.
  • 기간, 물음표, 느낌표 또는 콜론으로 끝나는 선이 계속 꺼져 있습니다. (Outlook은 그것이 문장의 끝이라고 가정합니까?)
  • 연속을 끄는 라인은 라인 브레이크로 시작되지만 40 자 미만이면 계속 켜집니다.
  • 탭으로 시작하거나 끝나는 줄은 계속 꺼집니다.
  • 2 개 이상의 공간으로 시작하는 라인은 계속 꺼집니다.
  • 3 개 이상의 공간으로 끝나는 라인은 계속 꺼집니다.

Outlook 2007 로이 모든 것을 시도했습니다. YMMV.
따라서 가능하면 문장 종료 구두점 마크, 탭 또는 세 개의 공간으로 모든 총알 항목을 종료하십시오.

줄 바꿈(CRLF) 바로 앞에 하나(또는 두 개의?) 탭 문자( )를 첨부하면 Outlook에서 강제로 줄 바꿈을 할 수 있습니다.

예:

This is my heading in the mail\t\n
Just here Outlook is forced to begin a new line.

Outlook 2010에서는 작동하는 것 같습니다.다른 버전에서도 작동하는지 테스트해 보세요.

또한보십시오 Outlook에서 줄 바꿈을 자동으로 정리하고 이메일 형식을 망쳐 놓았습니다.

Microsoft Outlook 2002 이상은 기본적으로 문자 메시지에서 "추가 라인 브레이크"를 제거합니다. (KB308319). 즉, Outlook은 단순히 모든 줄을 함께 실행하는 문자 메시지의 라인 피드 및/또는 캐리지 리턴 시퀀스를 무시하는 것 같습니다.

이로 인해 Outlook을 사용하는 사람이 읽을 이메일 메시지를 자동으로 생성하는 코드를 작성하려는 경우 문제가 발생할 수 있습니다.

예를 들어, 명확성을 위해 별도의 정보를 별도의 라인에 제공한다고 가정 해 봅시다.

거래에주의가 필요합니다!
Posteddate : 2009 년 1 월 30 일
금액 : $ 12,222.06
전송 : 8GK288G229G2KG89
우편 코드 : 91543

귀하의 Outlook 수신자는 다음과 같이 정보가 모두 부서진 것을 볼 수 있습니다.

거래에주의가 필요합니다! PostedDate : 2009 년 1 월 30 일 금액 : $ 12,222.06 Transid : 8GK288G229G2KG89 ZIPCODE : 91543

쉬운 해결책이없는 것 같습니다. 대안은 다음과 같습니다.

  1. 당신은 공급할 수 있습니다 각 줄 사이의 선 세트가 나옵니다. 이는 Outlook이 한 줄에 라인을 결합하는 것을 중지하지만 각 줄 사이에 추가 빈 줄을 표시합니다 (반대 문제를 만듭니다). "두 줄의 선을 공급"한다는 것은 " r n r n"또는 " r r"또는 " n n"을 사용하지만 " r n"또는 " n을 사용해야한다는 것을 의미합니다. 아르 자형".
  2. 이메일 메시지 본문의 모든 줄의 시작 부분에 두 개의 공간을 제공 할 수 있습니다. 각 라인 사이에 여분의 빈 줄을 도입하지 않습니다. 그러나 이것은 메시지의 각 줄이 상당히 짧은 경우 가장 잘 작동합니다. 사용자가 각 줄의 끝을 다음 줄의 첫 번째 위치로 감싸는 매우 좁은 Outlook 창에서 텍스트를 미리 볼 수 있기 때문입니다. 두 공간에 인한 라인과 정렬하십시오. 이 전략은 일부에 사용되었습니다 뉴스 레터.
  3. 일반 텍스트 형식 사용을 포기하고 HTML 형식을 사용할 수 있습니다.

나는 같은 문제가 있었고 해결책을 찾았습니다. 이 시도: %0D%0A 라인 브레이크를 추가합니다.

" n"대신 HTML 라인 브레이크를 사용했습니다. 잘 작동했습니다.

" r n"대신 " t r n"( t)를 추가하면 2010 년 Outlook에서 저에게 효과가있었습니다. 참고 : 각 라인의 끝에 3 개의 공간을 추가하면 같은 일이 있지만 프로그래밍 해킹처럼 보입니다!

HTML 이메일을 보내야합니다. 와 함께 <br />S 전자 메일에서는 항상 라인이 나옵니다.

I had been struggling with all of the above solutions and nothing helped here, because I used a String variable (plain text from a JTextPane) in combination with "text/html" formatting in my e-mail library.

So, the solution to this problem is to use "text/plain", instead of "text/html" and no need to replace return characters at all:

MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(message, "text/plain");

Put the text in <pre> Tags and outlook will format and display the text correctly.

i defined it in CSS inline in HTML Body like:

CSS:

pre {
 font-family: Verdana, Geneva, sans-serif;
}

i defined the font-family to have to font set.

HTML:

<td width="70%"><pre>Entry Date/Time:       2013-09-19 17:06:25
Entered By:     Chris

worklog mania

____________________________________________________________________________________________________

Entry Date/Time:        2013-09-19 17:05:42
Entered By:     Chris

this is a new Worklog Entry</pre></td>

Because it is a query, only percent escaped characters work, means %0A gives you a line break. For example,

&lt;a href=&quot;mailto:someone@gmail.com?Subject=TEST&amp;amp;body=Hi there,%0A%0AHow are you?%0A%0AThanks&quot;&gt;email to me&lt;/a&gt;

The trick is to use the encodeURIComponent() functionality from js:

var formattedBody = "FirstLine \n Second Line \n Third Line";
var mailToLink = "mailto:x@y.com?body=" + encodeURIComponent(formattedBody);

RESULT:

FirstLine
SecondLine
ThirdLine

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

\r\n will not work until you set body type as text.

message.setBody(MessageBody.getMessageBodyFromText(msg));
BodyType type = BodyType.Text;
message.getBody().setBodyType(type);

RESOLVED IN MY APPLICATION

In my application, I was trying to send an email whose message body was typed by the user in text area. When mail was send, outlook automatically removed line break entered by user.

e.g if user entered
Yadav
Mahesh

outlook displayed it as
YadavMahesh

Resolution: I changed the line break character "\r\n" with "\par " ( remember to hit space at the end of RTF code "\par" )and line breaks are restrored.

Cheers,
Mahesh

If you can add in a '.' (dot) character at the end of each line, this seems to prevent Outlook ruining text formatting.

Try this:

message.setContent(new String(body.getBytes(), "iso-8859-1"),
                    "text/html; charset=\"iso-8859-1\"");

Regards, Mohammad Rasool Javeed

Try \r\c instead of \n.

EDIT: I think @Robert Wilkinson had it right. \r\n. Memory just isn't what it used to be.

The \n largely works for us, but Outlook does sometimes take it upon itself to remove the line breaks as you say.

I have a good solution that I tried it, it is just add the Char(13) at end of line like the following example:

Dim S As String
 S = "Some Text" & Chr(13)
 S = S + "Some Text" & Chr(13)

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

This must be helpful for you. try "%0A" instead of "\n". The real source is here.

You need to add "%0A" where ever you need a new line in your code. In your case

 abcParameters.put(defConstants.REPORT_MESSAGE, "Invalid file sent by tt. Hence ffgghh  was unable
              to process it : " + s+ "%0A" +e.getMessage().toString());

I also had this issue with plain/text mail type. Earlier, I used "\n\n" but there was two line breaks. Then, I used "\t\n" and it worked. I was using StringBuffer in java to append content.
The content got printed in next line in Outlook 2010 mail.

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

Sometimes you have to enter \r\n twice to force outlook to do the break.

This will add one empty line but all the lines will have break.

if work need to be done with formatted text with out html encoding. it can be easy achieved with following scenario that creates div element on the fly and using <pre></pre> html element to keep formatting.

var email_body = htmlEncode($("#Body").val());

 function htmlEncode(value) {
    return "<pre>" + $('<div/>').text(value).html() + "</pre>";
}

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top