我正在尝试使用 Excel 打开 Outlook 2010 电子邮件模板。我收到以下错误:
"Run-time error '-2147287038 (80030002)':
Cannot open file:
C:\My\Path\MyTemplate.oft. The file may not exist, you may not have permission to open it, or it may be open in another program. Right-click the folder that contains the file, and then click Properties to check your permissions for the folder."
该文件存在(在正确的位置),我检查了权限(据我所知),并且该文件未打开。
Sub Mail_experiment()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.mailitem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate("C:\My\Path\MyTemplate.oft")
On Error Resume Next
With OutMail
.to = "myEmail@aol.com"
.CC = ""
.BCC = ""
.Subject = "This is my Subject line"
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
最佳答案
“我在另一台计算机上尝试了我的代码并且它有效。我返回并更改了模板的文件名,因为以前的名称全部大写(应该没关系,对吧?)。我收到一条消息关于需要成为管理员才能执行此操作,我认为这很奇怪,因为这是我的个人家用计算机。但是,当我单击“继续”时,它继续并更改了名称。现在它可以工作了。 – David Elphee Sep 14 ' 14 点 13:23"
关于excel - 如何使用 Excel VBA 打开 Outlook 电子邮件模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25829685/