How can I know whether Outlook is configured or not programmatically? - c#

I want to know how can I know whether Outlook is configured or not using c# in winforms?
I found something on this
http://www.outlookbanter.com/add-ins-outlook/94961-out-check-whether-outlook-configured.html
but don't think it's relevant.
The above link shows approach using registry.
I want to know is there any other way except inspecting registry?

Check following link
How to detect whether Outlook is configured on machine using Regis
As described here, you can perform following check from registry entry
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles
If you find any folder inside this 'Profiles' folder, then the Outlook is
configured for the current user.

Related

Outlook Addin Installation and Deployment(userwise and machinewise)

We have developed a Outlook Add In. I wish to deploy this add in in both Single User / Multi user environment
I have managed to deploy this Add In for single user environment. I am adding a Registry Entry (HKCU) for single user and the add in gets installed under "APPDATA\ROAMING\CompanyName\AddInName." I am using standard MSI for installation
But the issue I face is even if i ran the Installer, I don't see Add In appearing under Outlook, unless, I browse to the installation path (as above) and double click on VSTO file and deploy it again.
For Terminal Server / Citrix based implementation, I am trying to change the Registry to HKLM but not 100% sure how this will work.
My question is that
1. How I can have deploy this Outlook Add in only in one attempt. I don't want to install and then deploy (double click VSTO) file?
2. How I can deploy this add in for Terminal Server / Citrix based implementation?
I have gone through various blogs but they are not very clear and cause more confusion.
Would appreciate your expert suggestions
Thanks
Unfortunately I can only answer the first part of your question - You will have to create registry entries so that when Outlook is started it automatically applies your installed add in. See the link below for a detailed explanation of the registry keys that are required. https://msdn.microsoft.com/en-us/library/bb386106.aspx
In short, You need to add a registry entry for your add in that contains a FriendlyName, Description, LoadBehavior and Manifest input. Directing to the following link will tell you exactly how to do this and exactly where to put the keys. https://msdn.microsoft.com/en-us/library/cc442767.aspx#To-create-registry-keys
Best of luck and If you have any issues with that, comment below and I will help you as soon as I can.
**As an added note, I once had problems similar to the one you are having, and in my case it was due to the LoadBehavior setting. I was using the "UK Spelling" of the word instead of the US spelling. LoadBehavior must be specified exactly as I have written it here.

Cannot create StorageItem in Outlook Add-In

I'm trying to run this code:
this.storage =
Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
.GetStorage("ws_up_storage", Outlook.OlStorageIdentifierType.olIdentifyByMessageClass);
It runs perfectly well on some machines, but on others it throws this exception:
I also tried other folder names, like olFolderInbox, olFolderCalendar. I've looked at Microsoft docs for this, and it says this error is to be expected if the folder is one of the following:
The folder is a Microsoft Exchange public folder, an Internet Message Access Protocol (IMAP), MSN Hotmail, or a Microsoft SharePoint Foundation folder.
The user permission for the folder is read-only.
The store provider does not support hidden items.
The sad fact is, I do not know how to check which one of these is true and if it's at all possible.
How would I go about determining the cause of the problem and addressing it?
The easiest way to handle all these cases is to try to get a storage. You will need much efforts to implement all cases. The PR_MDB_PROVIDER property allows to identify the store provider, but not all cases such as user permissions for the folder and etc. You can use the try/catch block where you may check the error code - 0x80040102 (MAPI_E_NO_SUPPORT).
However, you may use any low-level property viewers (for example, a free open source tool - MFCMAPI) for exploring Extended MAPI property values. Thus, you may find all the required info about not supported scenarious.
The error 0x80040102 is MAPI_E_NO_SUPPORT, which means the store does not support hidden (associated) items.
Read the PR_MDB_PROVIDER property (DASL name http://schemas.microsoft.com/mapi/proptag/0x34140102) using PropertyAccessor.GetProperty. The returned 16 byte array will be specific for each store kind. E.g. for an Exchange store, it will be pbExchangeProviderPrimaryUserGuid (5494A1C0297F101BA58708002B2A2517). Take a look at any object in the store in question using OutlookSpy (I am its author - click IMessage, IMAPIFolder, or IMsgStore) to see the PR_MDB_PROVIDER property.

Embed individualized code into ClickOnce setup.exe?

I know that it is possible to pass in parameters via URL to ClickOnce apps launched online. However, most users downloads setup.exe and launch it from their machine. Is there any way that I can re-write setup.exe at download, insert a code (let's say the user's email address), and then have the app launch with knowledge of the code? Assume that we can somehow re-sign setup.exe so that it is legit.
Assume .NET 3.5.
Update The goal here is to pass on either email address and/or referrer information to setup.exe so that even when the user runs the installer from a different machine and a different ip we can figure out who did the referral.
Update 2 Assume .NET 3.5 SP1, does it help? Apparently one can now pass parameters to .application while offline. Is it possible to embed parameters into the setup.exe so that it calls .application?ref=someone right when setup.exe is run?
Well, if your goal is to embed a customer id (email, code, etc) into the exe, the easiest way I can think of is using the IPropertyStorage and IPropertySetStorage interfaces. If you are feeling brave, you could call methods directly on IPropertySetStorage via p/invoke, or you could go the easy route and use Microsoft's prepared COM wrapper, which is called dsofile.dll.
Note that while dsofile is intended for office documents, it does indeed work on any file - including .exe files - you are just stuck with the pre-defined property names. Why not throw your customer id into something like the .Comments property. Just do it in such a way that you can parse it out again.
Here's a sample:
var doc = new OleDocumentPropertiesClass();
doc.Open(pathToFile);
doc.SummaryProperties.Comments = "joe#test.com";
doc.Save();
Of course, you need to first copy it to a temp location, and some time after the user downloads it you'll want to delete it.
You can bundle dsofile.dll with your application and register it as a dependancy and use it in your installer to read the property back out. Or if you can p/invoke the IPropertyStorage without it, then you won't have the dependancy.
The other thing to look into would be using the extended file properties that are read by the Shell32.dll. I just haven't been able to find a clean way to write them easily. If you go this route, please share how you wrote the properties to your .exe.
Have a look whether InPlaceHostingManager class can help you in this case. It won't probably do exactly what you have asked for. But may be able to help...
Any ClickOnce application based on an .exe file can be silently
installed and updated by a custom installer. A custom installer can
implement custom user experience during installation, including custom
dialog boxes for security and maintenance operations. To perform
installation operations, the custom installer uses the
InPlaceHostingManager class.
Walkthrough: Creating a Custom Installer for a ClickOnce Application
EDIT
I am not sure whether you could achieve what you want exactly in the way that you have described in the question. Check whether these threads help you.
Accessing Local and Remote Data in ClickOnce Applications
How to include custom data files in ClickOnce deployment?
How to: Retrieve Query String Information in an Online ClickOnce Application
How would you imagine to "rewrite" setup.exe at download? if instead of opening your application with the provided link (url) users are downloading the file locally directly from the network share, you can't intercept this.
I would try to play with permissions and have the users to execute it from the link provided to them, but unable to connect directly to the share or web address and download it. Not sure this is possible anyway.
You can try embedding that information as a resource into the exe.
Here's a c++ example of updating a resource of an exe. http://msdn.microsoft.com/en-us/library/ms648008(v=vs.85).aspx#_win32_Updating_Resources
You should combine approach by Charith and Josh - essentially, configure your web server so that you can generate a new setup based on URL parameters. Use custom installer to read from the referral information from resource for setup.exe. Check this link for how to manipulate resources for a native application in C# - you have to write to resource file while generating setup and need to read it from your custom installer.
Yet another way of generating custom setup would be to build your executable or helper assemblt from command line embedding the necessary information. And then build the setup from command line tools (see http://msdn.microsoft.com/en-us/library/xc3tc5xx.aspx). It appears to be quite cumbersome and will take long time to generate the custom setup as opposed to modifying the resource of already built setup.
A completely different approach would be to email the unique referral code (registration code) whenever user downloads the application. In the setup (or application), use custom installer to prompt user for this code. If the setup is invoked via URL then the code will be available from there and in such case Custom Installer need not ask for the code. The email that you send when user download the setup should inform user to preseve the code into some text file along with the setup file.

Get write access to local_machine\software in the registry for .net application

I am trying to change the friendly name of a USB sound card. I can don't it from windows as well as edit the registry location using regedit. But I get an exception when I try to open the subkey for write access.
Is there any way to get around this. For now my work around is to build the correct registry import file and run that, but I would like it much better if it could be implemented in code.
Are you running your c# application as an administrator? Only a user with administrative rights has access to write to HKLM.
The way I got around this is to write a text file in the format that can be imported into the registry and just call that file using Process.Start("edit.reg") or what ever you named your file. Works for now, only need to do this once on installation, for now.

List all applications that handle a specified file type

Is it possible to list all the applications on a machine that can open a specific file type, using only the files extension? for example if I have a text file (.txt), I want a list of all applications that can open .txt files.
Check out the HKEY_CLASSES_ROOT hive in your registry. It's all in there.
There is no master list of every application that can open a specific file that I am aware of.
I am assuming you are talking about Windows machines...
You can only go so far as listing the applications that are registered has to able of handling a specific file extension (the same applications that show up when you right click and select "Open With"). This is somewhere in the Windows Registry.
I would suggest you to check on the microsoft documentation, or open your registry and start searching for known extensions.

Categories