使用vbscript在后台将msg转换为html [英] convert msg to html in background using vbscript

查看:123
本文介绍了使用vbscript在后台将msg转换为html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Outlook msg文件转换为html文件.到目前为止,我有:

I'm converting an Outlook msg file to an html file. So far I have:

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将在脚本的持续时间内打开.

I'd like this to run in the background (without disturbing the user who runs it). Do I have to start an Outlook process? As it currently stands, if the user has Outlook open, then the above script closes Outlook and I can understand why (outlookapp.Quit). If Outlook isn't open when the script is run, Outlook opens for the script's duration.

有人可以朝正确的方向推我吗?谢谢!

Can someone please nudge me in the right direction? Thank you!

推荐答案

为什么需要调用Application.Quit?如果Outlook正在运行,它将保持运行状态.如果未运行,则在取消引用所有Outlook对象时,Outlook会自行关闭-请记住,Outlook是单例,并且CreateObject将连接到已在运行的实例.您不会获得全新的流程.

Why do you need to call Application.Quit? If Outlook was running, it will stay running. If it was not running, Outlook will close itself when you dereference all Outlook objects - keep in mind that Outlook is a singleton and CreateObject will connect to the already running instance; you do not get a brand new process.

如果您不想使用Outlook,则可以使用兑换(它不会启动Outlook) :

If you do not want to use Outlook, you can use Redemption (it will not start Outlook):

  set Session = CreateObject("Redemption.RDOSession")
  set Msg = Session.GetMessageFromMsgFile("c:\temp\test.msg")
  Msg.SaveAs "c:\temp\test.html", 5

这篇关于使用vbscript在后台将msg转换为html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆