Reputation: 1
I need some help because I'm having some troubles..
I'm using Visual Studio 2012 and coding in C#. A little application.
I explain my issue :
I have a button who calls a script file name_script.vbs
On the name_script.vbs
:
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItemFromTemplate("PATH")
myItem.Display
In C# button :
System.Diagnostics.Process.Start(@"\\Patch_to_the_script\name_script.vbs");
I have put on the top of my application :
Using Microsoft.Office.Interop.Outlook;
using Microsoft.Win32;
In my laptop is working but in other laptop not working
If I open directly the script.vbs
It's works ! Directly !
But in others laptops, Error: ActiveX can't create object 'Outlook.Application'
..
I have launched with cscript but no changes ..
Maybe a problem in the compilation with a DLL ?
Did you have some ideas of this problem ?
Thanks in advance
I also try this :
Microsoft.Office.Interop.Outlook.Application application = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.Folder f = application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDrafts)
as Microsoft.Office.Interop.Outlook.Folder;
Microsoft.Office.Interop.Outlook.MailItem mail =
application.CreateItemFromTemplate(@"\\Path\template.oft", f)
as Microsoft.Office.Interop.Outlook.MailItem;
mail.Display();
and this :
System.Diagnostics.Process repousse= new Process();
string targetDir = string.Format(@"\\path\");
repousse.StartInfo.WorkingDirectory = targetDir;
repousse.StartInfo.FileName = "script.vbs";
repousse.StartInfo.CreateNoWindow = false;
repousse.Start();
repousse.WaitForExit();
And here to : Cscript
Upvotes: 0
Views: 614
Reputation: 67918
The issue is that the client machine doesn't have the appropriate classes registered for Outlook interop. This could happen for an enumerable number of reasons, some of which include:
.vbs
extension isn't registered properly,Though there are other reasons that could be the culprit, I believe one of the aforementioned are likely the issue. Further, the using
statements in your application are irrelevant. The .vbs
file isn't going to use those using
statements.
Upvotes: 1