如何使用php生成outlook msg文件[关闭]

i'm trying generate msg file with php. Headers;

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 ");

But i'm getting an error message when open

File content:

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--
dsp1836
dsp1836 “该文件可能不存在,也许你没有权限或它在其他应用程序上打开”Outlook工作,所以我打开msg文件,但它无法打开用php动态创建的msg文件
7 年多之前 回复
duan36000
duan36000 您收到了什么错误消息?为什么不输出任何内容以与这些HTTP标头一起使用?
7 年多之前 回复
duanbai5348
duanbai5348 你能在你的问题中添加错误信息吗?有四个不同的Content-Type标题有什么关系吗?
7 年多之前 回复

1个回答



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

您可以显式创建MSG文件(其格式已记录)或使用第三方库 ,例如 Redemption (使用 RDOSession .CreateMessageFromMsgFile)。</ p>
</ div>

展开原文

原文

This is not an MSG file, this is an EML (MIME) file. MSG file is as binary as it gets - it is an OLE storage (IStorage) file.

You can either create the MSG file explicitly (its format is documented) or use a third party library, such as Redemption (use RDOSession.CreateMessageFromMsgFile).

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐