JavaMail + HTML

Pagina: 1
Acties:

  • B-Man
  • Registratie: Februari 2000
  • Niet online
Ik verzend HTML mails met JavaMail en liep tegen een probleem aan: een aantal HTML mails worden inmijn mailclient weergegeven als text, van een paar andere mails zie ik de HTML broncode... het betreft HTML die door anderen in een db gecopy&paste is in een MySQL database.

Het enige verschil dat ik kan ontdekken is de "Content-Transfer-Encoding"-header: voor de mails die goed weergegeven worden is deze nl. "7bit", voor de mails waar ik de broncode van zie is deze "quoted-printable".

Hoe zorg ik ervoor dat alle mail goed weergegeven wordt ?

MimeUtility.encodeText(tekst, "ISO-8859-1", null) zorgt er slechts voor dat ik nog meer troep te zien krijg.

De HTML staat in de database met geconverteerde HTML-chars (< = & lt;, enz), dit wordt door JavaMail automatisch omgezet naar de originele chars.

BvD

  • B-Man
  • Registratie: Februari 2000
  • Niet online
Het is rustig vandaag...

  • B-Man
  • Registratie: Februari 2000
  • Niet online
Ik ben er inmiddels, na het lezen van wat RFC's achter dat quoted-printable aangeeft dat er speciale karakters in de tekst voorkomen, die niet binnen de 7bit encoding vallen.

Waarom outlook express sommige berichten die wel 7bit zijn, en qua HTML correct zijn niet goed laat zien blijft me een raadsel...

Is iemand bekend met dit probleem?

  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
Ik denk dat je het Content-Type niet goed instelt:

Voor HTML mail is deze header noodzakelijk:
code:
1
Content-Type: text/html

Voor plain text:
code:
1
Content-Type: text/plain

Misschien zijn er mail-clients die zonder dat jij Content-Type text/html opgeeft toch uit gaan vissen dat het html is, vandaar dat hij het soms wel doet.

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
Oeps, ik zat net te reageren :o , dit was dus geen reactie op jouw tweede reactie..

Staat je encoding ook goed?

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


  • B-Man
  • Registratie: Februari 2000
  • Niet online
Bijvoorbeeld:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Received: from [xx.xx.xx.xx] ([192.168.0.3]) by ntserver.xxxx.nl with Microsoft SMTPSVC(5.0.2195.2096);
     Wed, 2 Jan 2002 21:02:12 +0100
Received: from [192.168.1.2] (helo=TRANSPON-BG)
    by [xx.xx.xx.xx] with esmtp (Exim 3.31 #2)
    id 16LrVO-0005KN-00
    for xx@xxxxx.nl; Wed, 02 Jan 2002 20:56:54 +0100
Message-ID: <2623667.1010001538156.JavaMail.Administrator@xxxxx>
From: xx xxxx <xx@xxxxx.nl>
To: xx xxxx <xx@xxxx.nl>
Subject: Lees hier waar ISWD DeMT voor kan inzetten
Mime-Version: 1.0
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
Date: Wed, 02 Jan 2002 20:56:54 +0100
Return-Path: xxx@xxxxx.nl

<FONT face=3Darial><SPAN style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-=
bidi-font-size: 12.0pt">Geachte ...,</SPAN><SPAN style=3D"FONT-SIZE: =
10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">&nbsp;<?xml:namespace=
 prefix =3D o ns =3D "urn:schemas-microsoft-com:office:office" /><o:p></o:p=
></SPAN><FONT size=3D2> </FONT></FONT>
<P class=3DMsoBodyText><FONT face=3Darial><FONT size=3D2>Ik informeerde u r=
eeds eerder over ... DeMT is g=
...) die ... voor u per k=
....&nbsp;&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoBodyText><FONT face=3Darial><FONT size=3D2>U bepaalt met DeMT=
 zelf de inhoud, volgorde, tijdstip en voorwaarden. Standaard heeft DeMT de=
 volgende belangrijke functionaliteiten:&nbsp;<o:p></o:p></FONT></FONT></P>
<UL>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</F=
ONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT=
></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV=
>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial size=3D2=
>...</FONT></DIV>
<LI>
<DIV class=3DMsoBodyText style=3D"MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt; ta=
b-stops: list 36.0pt; mso-list: l0 level1 lfo3"><FONT face=3Darial><FONT si=
ze=3D2>Tot ...<SPAN style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12=
.0pt; mso-bidi-font-style: italic">&nbsp;<o:p></o:p></SPAN></FONT></FONT></=
DIV></LI></UL>
<P class=3DMsoNormal style=3D"tab-stops: 117.0pt 234.0pt 351.0pt"><SPAN sty=
le=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt; mso-=
bidi-font-style: italic"><A href=3D"http://www.ma-re-con.nl/doors/demt.htm"=
><FONT face=3Darial>Klik hier </FONT></A><FONT face=3Darial>en lees hoe u D=
eMT voor ISWD kunt inzetten.</FONT></SPAN><SPAN style=3D"FONT-SIZE: 10pt; F=
ONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt; mso-bidi-font-style: italic"=
><FONT face=3Darial>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal style=3D"tab-stops: 117.0pt 234.0pt 351.0pt"><FONT fac=
e=3Darial><SPAN style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font=
-size: 12.0pt">Met vriendelijke groet,</SPAN><SPAN style=3D"FONT-SIZE: 10pt=
; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt">&nbsp;<o:p></o:p></SPAN><=
/FONT></P>
<P class=3DMsoNormal style=3D"tab-stops: 117.0pt 234.0pt 351.0pt"><SPAN sty=
le=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"><FON=
T face=3Darial>Namens Doors International<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal style=3D"tab-stops: 117.0pt 234.0pt 351.0pt"><SPAN sty=
le=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"><FON=
T face=3Darial>&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal style=3D"tab-stops: 117.0pt 234.0pt 351.0pt"><SPAN sty=
le=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"><FON=
T face=3Darial>Ing F.J.A. Zegers<o:p></o:p></FONT></SPAN></P>
<P class=3DMsoNormal style=3D"tab-stops: 117.0pt 234.0pt 351.0pt"><SPAN lan=
g=3DEN-GB style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-bidi-font-size:=
 12.0pt; mso-ansi-language: EN-GB"><FONT face=3Darial>Directeur Business un=
it Marketing<o:p></o:p></FONT></SPAN></P>

Als ik deze mail ontvang in outlook express, zie ik de letterlijke HTML codes ipv het opgemaakte bericht zelf

  • B-Man
  • Registratie: Februari 2000
  • Niet online
Ik kan er geen touw aan vastknopen:

ik dacht eerst dat het aan de office-codes lag, maar dat is niet het probleem. De encoding ook niet, aangezien ik sommige 7bit mails wel goed zie, sommige niet, en quoted-printable alleen maar als HTML broncode.

  • B-Man
  • Registratie: Februari 2000
  • Niet online
Ja, mijn encoding staat volgens de RFC dus goed. Het lijkt erop dat Outlook express sommige HTML niet slikt ofzo...

  • Sircuri
  • Registratie: Oktober 2001
  • Niet online

Sircuri

Volledig Appelig

Op een hele boel plaatsen in die HTML code staat de letter 'D'. Heb je daar wel eens naar gekeken, want die html code die je hier geplakt hebt is geen geldige html code op deze manier.

Signature van nature


  • Jelmer
  • Registratie: Maart 2000
  • Laatst online: 07:53
Naar mijn weten worden html mailtjes altijd als multipart mime verstuurd...
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From newz@ganz.nl  Tue Dec 25 12:02:56 2001
Delivered-To: me@mydomain.com
From: "Newz" <newz@ganz.nl>
To: <Undisclosed-Recipient:;@jelmerbarhorst.com>
Subject: Opdracht 4
Date: Tue, 25 Dec 2001 12:00:19 +0100
MIME-Version: 1.0
Content-Type: multipart/related;
      type="multipart/alternative";
      boundary="----=_NextPart_000_00C2_01C18D3B.BAB38A80"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-Status: A
X-Keywords:
X-UID: 703

This is a multi-part message in MIME format.

------=_NextPart_000_00C2_01C18D3B.BAB38A80
Content-Type: multipart/alternative;
      boundary="----=_NextPart_001_00C3_01C18D3B.BAB38A80"


------=_NextPart_001_00C3_01C18D3B.BAB38A80
Content-Type: text/plain;
      charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Ganz.nl Extra Editie

***********hier staat body in plain text*****************

------=_NextPart_001_00C3_01C18D3B.BAB38A80
Content-Type: text/html;
      charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>.....

**********hier staat de body in html**************

  • B-Man
  • Registratie: Februari 2000
  • Niet online
Op donderdag 03 januari 2002 13:16 schreef Sircuri het volgende:
Op een hele boel plaatsen in die HTML code staat de letter 'D'. Heb je daar wel eens naar gekeken, want die html code die je hier geplakt hebt is geen geldige html code op deze manier.
Dat is dus de "quoted-printable"-encoding: deze werkt met identifiers als =3D en =9N enzovoorts.

  • B-Man
  • Registratie: Februari 2000
  • Niet online
Ik heb het nu aan de praat, het lijkt erop dat het niets met de encoding te maken had, maar met de HTML engine in Outlook Express.

Ik voeg nu de regel
code:
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

toe aan iedere mail (in het MIME blok dat de HTML bevat), en nu wordt alles perfect weergegeven.

Tevens heb ik ervoor gezorgd dat alle mail quoted-printable wordt verzonden.
Pagina: 1