excel - 如何使用 Excel VBA 打开 Outlook 电子邮件模板?

标签 excel vba email outlook

我正在尝试使用 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/

相关文章:

excel - Find() 返回 "object variable or with block variable not set"

javascript - 使用多个 Math.pow 将 Excel 公式转换为 Javascript

excel - sumif 某些列的值基于其他列

VBA Timer - 减去等待用户输入的时间

excel - 在单个按钮中运行功能的程序(1 个功能 = 1 次单击)

.net - 在 Visual Studio 2005 : Problems sending E-Mail 中将旧代码从 System.Web.Mail 更新为 System.Net.Mail

java - 使用 JavaMail 创建带有附件的 EML 文件

excel - VBA:将引用左侧的行中的值相加

vba - 超链接到 Excel 中另一个工作表上的单元格

Python、IMAP 和 GMail。将消息标记为已读