通过第三方批处理getmail可以获取到邮箱里的邮件。获取后经其自身解码,得到一个Extract*.out文件,大致看一下其格式应该为html的写法,并且内容只分一行。

<div dir="auto">here is the content</div>

显然我邮件发送的原内容为:

here is the content

现在要提取出其中的原内容并且将所有内容合并到一行。问题在于,邮箱不一定每次都接收到这样简单的文件。例如内容当中出现换行:

<div dir="auto">abababababababab<br /><br />abababababababab<br /><br /></div>

有时内容含特殊字符,解码之后也无法正常显示(某些字符):

i wanna get these words # $ % & * @ ? !
<div dir="auto">i wanna get these words # $ % &amp; * &#64; ? !</div>

有时发送的内容经过复制粘贴,不小心留下了其他信息:

<div dir="auto">hey get it <span style="font-family:sans-serif">hey get it </span><br style="font-family:sans-serif" /><span style="font-family:sans-serif">hey get it </span><span style="font-family:sans-serif">hey get it </span><br style="font-family:sans-serif" /></div>

显然需要忽略<>标签里的所有内容才能得到原内容,并且需要还原未正常显示的符号。
可能要用到第三方了……

原文地址:http://www.bathome.net/viewthread.php?from=notice&tid=64776