Posílám kus kódu z mé app. posílá to ale v html a včetně příloh (takové jsem měl zadání). Snad se v tom dá vyznat...
// Create a message part to represent the body text BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setContent(bodyInHTML, "text/html; charset=UTF-8"); //$NON-NLS-1$ Multipart multipart = new MimeMultipart(); // add the message body to the mime message multipart.addBodyPart(messageBodyPart); // append attachments if (attachments != null) { for (String file : attachments) { BodyPart append = new MimeBodyPart(); FileDataSource fds = new FileDataSource(file); if (fds.getFile().canRead()) { append.setDataHandler(new DataHandler(fds)); append.setFileName(fds.getFile().getName()); multipart.addBodyPart(append); } } } msg.setContent(multipart); Transport.send(msg); s pozdravem Vladimír Náprstek RWE Interní služby, s.r.o Aplikační kompetenční centrum Klíšská 940, 401 17 Ústí nad Labem Tel. (vnitřní): (984) 5102 Tel. (vnější): +420 475 325 102 Mobile: +420 739 535 915 E-mail: vladimir.naprs...@rwe.cz Dusan Zatkovsky píše v Po 30. 11. 2009 v 13:00 +0100: > Ahoj. > > Zapasim so $SUBJ a zacinam byt znacne strateny. > > Potrebujem poslat email pomocou java mail z windows, ktory ma v sebe cesky > text a attachment. Uz sa s tym lamem 2 hodiny a nemozem tomu prist na klb. > > Kod: > > MimeBodyPart text_part = new MimeBodyPart(); > text_part.setText(message_text); > text_part.setHeader("Content-Type", "text/plain; charset=\"" + > System.getProperty("file.encoding") + "\""); > text_part.setHeader("Content-Transfer-Encoding", "quoted-printable"); > > Nasledne to posielam ako multipart s attachmentom. > Vysledkom je, ze thunderbird to zobrazi ok, cokolvek ine (outlook) zle. > > Uryvok na disk ulozeneho multipart: > > Return-Path: <f...@test.cz> > Delivered-To: t...@test.cz > Received: (qmail 5290 invoked by uid 89); 30 Nov 2009 11:49:43 -0000 > Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys > DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; > s=private; d=test.cz; > b=YCY6ijt89eDlbCYX5hlSsXNTtBiPYnBECNPYxwcWN8Lv/+SvW7MAsx6YmGH0H406; > Received: from unknown (HELO xpprim) (dusan.zatkov...@test.cz@93.185.97.186) > by server1.test.cz with ESMTPA; 30 Nov 2009 11:49:43 -0000 > Date: Mon, 30 Nov 2009 12:49:43 +0100 (CET) > From: f...@test.cz > To: t...@test.cz > Message-ID: <28848200.5.1259581783779.javamail.ad...@xpprim> > Subject: =?Cp1250?Q?Zpr=E1v=E1_z_datov=E9_schr=E1nky_do_vlastn=EDch_ru?= > =?Cp1250?Q?kou_od_test,_s.r.o.,78501_=8Aternberk,_CZ?= > MIME-Version: 1.0 > Content-Type: multipart/mixed; boundary="----=_Part_3_8979901.1259581783639" > > ------=_Part_3_8979901.1259581783639 > Content-Type: text/plain; charset="Cp1250" > Content-Transfer-Encoding: quoted-printable > > Dne 09.10.2009 11:56:05 V=E1m byla doru=E8ena nov=E1 datov=E1 zpr=E1va s ID= > 101737. > -- CUT -- > ------=_Part_3_8979901.1259581783639 > Content-Type: application/octet-stream; name=message.zfo > Content-Transfer-Encoding: base64 > Content-Disposition: attachment; filename=message.zfo > > MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAaCAJIAEggPoPHE6 > TWVzc2FnZURvd25sb2FkUmVzcG9uc2UgeG1sbnM6cT0iaHR0cDovL2lzZHMuY3plY2hwb2ludC5j > -- CUT -- > > > Subject je dobre ( cesky ), telo uz nie. Skusal som rozne kombinacie charset > a > transfer encoding, vzdy to bolo zle. > > Bol by niekto taky dobry a pastol mi sem example s fungujucou cestinou? > Copy-pastol som asi 3 example z webu a ani jeden nezafungoval. > > Diky. > >