Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php生成outlook msg文件_Php_Outlook - Fatal编程技术网

如何使用php生成outlook msg文件

如何使用php生成outlook msg文件,php,outlook,Php,Outlook,我正在尝试用php生成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("Con

我正在尝试用php生成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: xxxx@domain.com
To: xxxx@domain.com
From: =?UTF-8?Q?T=C3=BCxxx_xxx?= <xxxx@domain.com>
Reply-To: =?UTF-8?Q?T=C3=BCxxx_xxx?= <xxxxx@domain.com>
Subject: =?UTF-8?B?ZmFsc2U=?=
Message-ID: <838dbc263c534dc099336c468b254365@example.com>
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--
日期:2013年5月10日星期五19:17:49+0300
返回路径:xxxx@domain.com
致:xxxx@domain.com
From:=?UTF-8?Q?T=C3=BCxxx\U xxx?=
回复:=?UTF-8?Q?T=C3=BCxxx\U xxx?=
主题:=?UTF-8?B?ZmFsc2U==
消息ID:
X优先级:3
X-Mailer:PHPMailer 5.2.2(http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME版本:1.0
内容类型:多部分/备选;
boundary=“b1_838dbc263c534dc099336c468b254365”
--b1_838dbc263c534dc099336c468b254365
内容类型:文本/纯文本;字符集=UTF-8
内容传输编码:8比特
测试
--b1_838dbc263c534dc099336c468b254365
内容类型:text/html;字符集=UTF-8
内容传输编码:8比特
测试
--b1_838dbc263c534dc099336c468b254365--

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


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

是否可以将错误消息添加到问题中?这与有四个不同的内容类型标题有关吗?您收到了什么错误消息?为什么不输出任何与这些HTTP头相关的内容?“该文件可能不存在,可能是您没有权限,或者是在其他应用程序上打开的”Outlook正常工作,因此我打开了msg文件,但无法打开使用php动态创建的msg文件