我如何使用php生成outlook msg文件

问题描述:

我正在尝试使用php生成msg文件。头;我如何使用php生成outlook msg文件

header("Pragma: public"); 
header("Expires: 0"); 
header('Content-Encoding: UTF-8'); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Content-type: application/vnd.ms-outlook;charset=UTF-8"); 
header("Content-Type: application/force-download"); 
header("Content-Type: application/octet-stream"); 
header("Content-Type: application/download");; 
header("Content-Disposition: attachment;filename=test.msg"); 
header("Content-Transfer-Encoding: binary "); 

但我收到错误消息时打开

文件内容:

Date: Fri, 10 May 2013 19:17:49 +0300 
Return-Path: [email protected] 
To: [email protected] 
From: =?UTF-8?Q?T=C3=BCxxx_xxx?= <[email protected]> 
Reply-To: =?UTF-8?Q?T=C3=BCxxx_xxx?= <[email protected]> 
Subject: =?UTF-8?B?ZmFsc2U=?= 
Message-ID: <[email protected]> 
X-Priority: 3 
X-Mailer: PHPMailer 5.2.2 (http://code.google.com/a/apache-extras.org/p/phpmailer/) 
MIME-Version: 1.0 
Content-Type: multipart/alternative; 
    boundary="b1_838dbc263c534dc099336c468b254365" 


--b1_838dbc263c534dc099336c468b254365 
Content-Type: text/plain; charset=UTF-8 
Content-Transfer-Encoding: 8bit 

test 

--b1_838dbc263c534dc099336c468b254365 
Content-Type: text/html; charset=UTF-8 
Content-Transfer-Encoding: 8bit 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
</head> 
<body rightmargin="0" leftmargin="0" bottommargin="0" topmargin="0" marginwidth="0" marginheight="0"> 
test 
</body> 
</html> 

--b1_838dbc263c534dc099336c468b254365-- 
+1

您可以将错误消息添加到您的问题?是否有四个不同的Content-Type标题? – andrewsi 2013-05-10 16:27:49

+0

**你得到了什么**错误信息?你为什么不输出任何内容去使用这些HTTP头文件? – Quentin 2013-05-10 16:29:43

+0

“该文件可能不存在,也许你没有权限或它在其他应用程序上打开”Outlook工作,所以我打开msg文件,但它无法打开用php创建动态msg文件 – 2013-05-10 16:34:25

这不是一个MSG文件,这是一个EML(MIME)文件。 MSG文件是二进制文件 - 它是一个OLE存储(IStorage)文件。

您可以显式创建MSG文件(其格式已记录),也可以使用第三方库,如Redemption(使用RDOSession .CreateMessageFromMsgFile)。