Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

c# Outlook and Application.CreateItemFromTemplate() relative path not working (help)

$
0
0

I have this function

static void Main(string[] args)
        {
            Outlook.Application application = new Outlook.Application();
            Outlook.MailItem mail = application.CreateItemFromTemplate("emailTemplate.oft") as Outlook.MailItem;
            mail.Subject = "My Subject";
            mail.To = "zara@zoro.bu; bora@zora.zu";
            mail.SaveAs("asdf.oft");
        }

But it is not working. Program crash when try open emailTemplate.oft. This file is under debug folder and when I provide full path to the file like this

"D:\full\path\to\the\file\emailTemplate.oft"

then file is opened and my code is working. Same for saveAs() function. It need full path. If I use FileStream for instance I don't need use full path for open file which is under my application exe file. How can I use CreateItmeFromTemplate() function to open file similar to FileStream? Is it possible?



Viewing all articles
Browse latest Browse all 2257

Trending Articles