2009-11-12 3 views

답변

10

아, 당신은 자바를 사용하고 있습니다.

제 의견으로는 HTML 전자 메일에서 일반 텍스트 대체물을 항상 설정해야합니다.

이 코드는 또한 인라인 이미지 (<img src="cid:foo">으로 HTML에서 참조 할 수 있지만 모든 전자 메일 클라이언트가이 기능을 지원.

MimeMessage mm = prepareMessage(from, to, subject, cc, bcc); 
MimeMultipart mp = new MimeMultipart("alternative"); 

// Attach Plain Text 
MimeBodyPart plain = new MimeBodyPart(); 
plain.setText(plainText); 
mp.addBodyPart(plain); 

/* 
* Any attached images for the HTML portion of the email need to be encapsulated with 
* the HTML portion within a 'related' MimeMultipart. Hence we create one of these and 
* set it as a bodypart for the overall message. 
*/ 
MimeMultipart htmlmp = new MimeMultipart("related"); 
MimeBodyPart htmlbp = new MimeBodyPart(); 
htmlbp.setContent(htmlmp); 
mp.addBodyPart(htmlbp); 

// Attach HTML Text 
MimeBodyPart html = new MimeBodyPart(); 
html.setContent(htmlText, "text/html"); 
htmlmp.addBodyPart(html); 

// Attach template images (EmailImage is a simple class that holds image data) 
for (EmailImage ei : template.getImages()) { 
    MimeBodyPart img = new MimeBodyPart(); 
    img.setContentID(ei.getFilename()); 
    img.setFileName(ei.getFilename()); 
    ByteArrayDataSource bads = new ByteArrayDataSource(ei.getImageData(), ei.getMimeType()); 
    img.setDataHandler(new DataHandler(bads)); 
    htmlmp.addBodyPart(img); 
} 

mm.setContent(mp); 
1

전자 메일 메시지의 해당 부분에서 Content-Type MIME을 text/html로 설정하고 있습니까?

Outlook을 사용하여 보는 중 - Outlook의 뷰어는 현명한 디자인처럼 IE 렌더링 엔진을 사용하는 대신 HTML을 렌더링하기 위해 Word의 모든 것을 사용합니다. 이는 중요한 서식을 잃을 수 있음을 의미합니다.

또는 다른 글꼴을 사용해보십시오. 몇 가지 글꼴은 굵게 변형을 정의하지 않습니다. 하지만 이것은 대부분의 글꼴 렌더링 기술이 아닌 굵은 글꼴을 자동 굵게 표시 할 수 있습니다.

1

이메일을 보내기 위해 사용하는 프로그래밍 언어.

모든 언어에서 옵션은 "IsBodyHtml"과 같아야합니다. 이 검사를 "참"으로하십시오. .NET 코드와 비슷합니다.

System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage(); mm.IsBodyHtml = true;

그래서 메일은 html 텍스트로 바뀝니다.

+0

내가 자바를 사용하고 – Harish

1

이 질문에 대한 답은 명확하지 않습니다. 일이 잘 안되는 데는 여러 가지 이유가 있습니다. 문제를 격리하려고 시도 할 수있는 몇 가지 사항입니다.

다른 HTML 태그가 인식되고 있습니까? 예. <p>, <a>? 그렇다면 <b> 대신 <strong> 태그를 사용해 보셨습니까?

이메일 리더에서 메시지 소스를 확인하십시오. '<'또는 '>'문자가 '& lt;'으로 이스케이프 처리 된 것일 수 있습니다. 또는 '& gt;' 그것이 보내지기 전에.

다른 리더에서 이메일을 보려고 했습니까? 웹 메일이나 데스크톱 기반으로 말 했나요? 글꼴 - 무게를 변경하는 CSS를 사용하여

시도 :

.important-text { font-weight: bold; } 

<span class=".important-text">Super important text</span>