dongqiongjiong4740 2016-05-10 11:55 采纳率: 0%
浏览 43

Str替换PHP中的oft文件

I have created an OFT file (Outlook template file) using the COM plugin through PHP. What I need to do is replace the URLs with dynamic URLs on the fly when a user downloads the files. I have opened the file in a text editor and using the code below and both register errors (using the code below Outlook simply wouldn't open "Unable to open outlook")):

<?php
$file = file_get_contents('email1.oft');
file_put_contents('email1.oft',str_replace('There is a new','hello world',$file));
echo 'Completed';
?>

So my question is (how) can one read an OFT file and do a str replace on it? And if so how?

  • 写回答

1条回答 默认 最新

  • douyang2530 2016-05-10 22:49
    关注

    OFT is the same format as MSG (its format is documented), just the class id is different. It is an IStorage, and Windows storage API (StgOpenStorage etc.) can be used.

    You can also Redemption, which can open and modify standalone MSG/OFT files (it requires the MAPI system to be installed, which means you need to have Outlook installed):

      set Session = CreateObject("Redemption.RDOSession")
      set Msg = Session.GetMessageFromMsgFile("c:\Temp\OldFile.oft")
      Msg.Body = Replace(Msg.Body, "oldf", "new")
      Msg.SaveAs "c:\Temp\NewFile.oft", 2 'olTemplate
    
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类