Trying to open Outlook email template using excel VBA

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

"Runtime error" -2147287038 (80030002): Unable to open file: C: \ My \ Path \ MyTemplate.oft. The file may be missing, you may not have permission to open it, or it may be opened in another program. Right-click the folder that contains the file and select Properties to check its permissions for this folder. "

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

Here is my code:

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 

Thanks for any help !!!

+3
source share
1 answer

“I tried my code on another computer and it worked. I went back and changed the name of my template, because the previous name was in all capitals (it doesn’t matter, right?). About the need to be an administrator to do this, which, in my opinion I thought it was strange because it’s my personal home computer. However, when I clicked “continue”, he went ahead and changed his name. Now it works. - David Alfie Sep 14 '14 at 13:23 "

+2
source

Source: https://habr.com/ru/post/989327/


All Articles