尝试使用excel VBA打开Outlook电子邮件模板 [英] Trying to open an Outlook email template with excel VBA

查看:899
本文介绍了尝试使用excel VBA打开Outlook电子邮件模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用Excel打开Outlook 2010电子邮件模板。我收到以下错误:

I am trying to open an Outlook 2010 email template with Excel. I get the following error:

运行时错误'-2147287038(80030002)':
无法打开文件:
C:\ My\Path\MyTemplate.oft。该文件可能不存在,您可能没有权限打开它,或者可能在另一个程序中打开。右键单击包含该文件的文件夹,然后单击属性以检查您的文件夹的权限。

"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."

该文件存在(在正确的地方),我已经检查了权限(据我所知),文件不是已经打开。

The file exists (in the right place), I have checked permissions (as far as I know how), and the file is not already open.

这是我的代码:

    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 at 13:23

"I tried my code on a different computer and it worked. I went back and changed the file name of my template, as the previous name was in all capitals (shouldn't matter, right?). I got a message about needing to be an administrator to do this, which I thought was strange since this is my personal home computer. However, when I clicked "continue" it went ahead and changed the name. Now it works. – David Elphee Sep 14 '14 at 13:23"

这篇关于尝试使用excel VBA打开Outlook电子邮件模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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