나는 javax를 사용하여 일부 메일을 읽었습니다.
그런 다음 메시지의 내용을 저장하려고합니다.전체 소스 코드없이 메일 내용을 얻는 방법은 무엇입니까?
예를 들어, 간단한 내용이 By: Test
인 메일을 읽었습니다.
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Arial","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE-CH" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">By: Test<o:p></o:p></span></p>
</div>
</body>
</html>
: IS,
By: Test
의 간단한 전자 메일 내용은 메시지의 전체 전망 소스 코드가 표시됩니다
Object body = message.getContent();
String content = ((body instanceof String) ? (String) body : "NO STRING CONTENT");
그러나 문제는 여기 :
는 지금은 .getContent()
방법으로 내용을 읽을
그래서 전체 메일 소스 코드를받지 않고 메일 내용을 읽을 수 있습니까?
HTML *은 내용입니다. 보낸 사람이 Outlook과 같이 나쁜 시민 일 경우 일반 텍스트 버전을 포함하지 않고 렌더링하거나 적어도 구문 분석해야합니다. – chrylis