2013-05-10 24 views
0

我正在嘗試使用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

回答

1

這不是一個MSG文件,這是一個EML(MIME)文件。 MSG文件是二進制文件 - 它是一個OLE存儲(IStorage)文件。

您可以顯式創建MSG文件(其格式已記錄),也可以使用第三方庫,如Redemption(使用RDOSession .CreateMessageFromMsgFile)。

相關問題