问题描述
我做了一个电子邮件客户端Android手机在JavaMail API。如果我试图让发件人的mail地址和收件人邮寄下列方法地址:
地址[] =弗罗马m.getFrom();
从= InternetAddress.toString(弗罗马)字符串; 地址[] = TOA m.getRecipients(Message.RecipientType.TO);
字符串= InternetAddress.toString(TOA);
我得到这样回字符串:
乔治·=?ISO-8859-1 Q + SP = E4the?=
并且它必须是乔治花苞或乔治Spaethe
我认为问题是,这是与其他编码的德国邮件。任何人可以帮助我解决这个问题?
MIME头都设有codeD根据的,因此,你需要先取消code它们。
字符串德codeD = MimeUtility.de codeTEXT(乔治·= ISO-8859-1 Q SP = E4the =????);
JDK导入:
进口javax.mail.internet.MimeUtility;
有关Android的:
进口com.android.email.mail.internet;
参见 的Javadoc / p> I made an E- Mail Client for my Android phone with the Javamail Api. If I try to get the sender's mail adress and the recipients mail adress with the following methods: I get a String like this back: "Georg =?ISO-8859-1?Q?SP=E4the?=and it has to be Georg Späthe or Georg Spaethe. I think the Problem is that this are German Mails with another encoding. Can anybody help me to solve that Problem? MIME headers are encoded as per RFC 2047, therefore you need to decode them first. JDK import: For Android: See also Javadoc of MimeUtility 这篇关于JavaMail的ISO-8859-1格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!Address[] froma = m.getFrom();
String from = InternetAddress.toString(froma);
Address[] toa = m.getRecipients(Message.RecipientType.TO);
String to = InternetAddress.toString(toa);
String decoded = MimeUtility.decodeText("Georg =?ISO-8859-1?Q?SP=E4the?=");
import javax.mail.internet.MimeUtility;
import com.android.email.mail.internet;