使用vbscript将msg转换为html背景
问题描述:
我将Outlook msg文件转换为html文件。到目前为止,我有:使用vbscript将msg转换为html背景
Dim objshell,BaseName,outlookapp,emailPath
Set objshell= CreateObject("scripting.filesystemobject")
Set outlookapp = CreateObject("Outlook.Application")
Set email = outlookapp.CreateItemFromTemplate(emailPath)
emailPath = "C:\Users\makkerman\Desktop\email folder\test.msg"
BaseName = objshell.GetBaseName(emailPath)
email.saveas objshell.GetParentFolderName(emailPath) & "\" & BaseName & ".html", 5
outlookapp.Quit
我希望这在后台运行(不打扰用户谁运行它)。我是否必须启动Outlook过程?就目前而言,如果用户打开了Outlook,那么上面的脚本会关闭Outlook,我可以理解为什么(outlookapp.Quit)。如果在脚本运行时Outlook未打开,则Outlook将打开该脚本的持续时间。
有人能请我正确的方向吗?谢谢!
答
为什么你需要调用Application.Quit?如果Outlook正在运行,它将保持运行。如果它没有运行,Outlook将在您取消引用所有Outlook对象时自动关闭 - 请记住,Outlook是单例,并且CreateObject将连接到已经运行的实例;你没有得到一个全新的过程。
如果你不想使用Outlook,您可以用Redemption(它不会启动Outlook):
set Session = CreateObject("Redemption.RDOSession")
set Msg = Session.GetMessageFromMsgFile("c:\temp\test.msg")
Msg.SaveAs "c:\temp\test.html", 5