How to change Outlook settings programatically with .net? - c#

I'm working on a script that generates a user in my network. Besides the AD, File-Share and Exchange part of it I want to set some default Outlook settings for the new user. As a start I want to change some calendar settings like holidays and calendar viewing permissions.
First of all I thought of the Microsoft.Office.Interop.Outlook Namespace. Sadly all parameters are read-only. So this didn't work out.
Then I came across this SO post and was confident as hell. Sadly as far as I tried and understand (Source: Understanding an Outlook profile file) you can't set those settings in a .prf-file.
And here I ran out of options.. There used to be a ADODB method to interact with Outlook. But as far as I know this doesn't work anymore since Exchange/Outlook 2010.
Thanks in advance for any shared thoughts.

I'm not sure what the answer is, but I can tell you how to find it. If you change those settings, close Outlook, and then configure Outlook on a different machine to connect to the same Exchange mailbox, do the settings persist? Probably not, in which case they're not stored in the mailbox.
If they're not stored in the mailbox, they're probably stored in the registry. Use procmon or a similar tool to monitor which keys Outlook modified when you change those settings. You should then be able to just set those keys in your program, but be aware that the exact key may vary with version of Outlook, so you'd want to ask your customer how many versions of Outlook they use in their environment.

Related

How to Read/Write Contacts and Events in Outlook when it is set to Work Offline - C#

As the Title suggest, i am trying to Read and Write (R&W) Contact and Event information to multiple Outlook Accounts/Profiles in a local computer, while Outlook is set to Work Offline.
So far i discovered two ways to R&W contacts and Events to Outlook:
1.- Microsoft.Graph:
This seems to work only online, since it reads and writes to the Microsoft server, not to the local pst/ost files.
2.- microsoft.office.interop.outlook library:
This does work offline/locally (by accessing the Outlook pst/ost files) but the approach i am using so far requires the creation of an Application object as
var app = new Microsoft.Office.Interop.Outlook.Application();
Nevertheless, creating an Application object implicitly logs in a profile/user to the application, and further, if Outlook is already running and logged in with a Profile X, the code above instantiates an Outlook object in which the Profile X is logged in, so in that scenario i can only R&W Contacts and Events for that specific user/Profile.
So, is there a way to be able to R&W Contact and Event information for different profiles independently of if Outlook is running with a Profile X?
Well, there is no magic - if you want offline access, something needs to implement the storage to keep the cached data and cache your changes so that they can be uploaded when the server comes back online.
If you don't want to implement that logic, cached Outlook profile is probably your only choice. You are right that Outlook, being a singleton, can only access one profile at a time. You can use Extended MAPI to access a profile other than the other used by Outlook, but it is C++ or Delphi only. If using Redemption is an option (I am its author), it wraps Extended MAPI API for use in any language (C# included) - you can use its RDOSession.Logon method to access any existing profile.

Change settings in Lync Client 2010

In our corporate environment we need to have the Privacy Mode in Lync 2010 enabled for a specific user group. Unforutnately it's only possible to enable this mode for the whole environment and not for specific users.
The idea is to enable the privacy mode via Lync policy for the whole environment and control the setting on the Clients with our software deployment system. It's possible to choose "I want everyone to be able to see my presence..." and "I want the system administrator to decide". What I'd need is a little client tool preferably written in C# which is able to change that Status option in the Lync 2010 client.
Unfortunately it seems like this is not simply a registry key being set. I found that there is a "PolicyPak" which is able to control this setting through Group Policies. Most likely they're using the LyncSDK to control this setting.
My questions is: Does someone know how to change this setting through the LyncSDK? I've already downloaded it but didn't really know where to start. Maybe someone can point me in the right direction.
From the research I've been able to do, I don't see any network traffic sent to the server or registry settings being modified.
This leads me to conclude the client (when setting this) loops through contacts and places them in the appropriate permission group. I'll revisit this post soon with findings and some code for testing purposes.
By using the UCMA it is possible to change the PrivacyMode for a user with the BeginUpdatePrivacyPreference method

Can an Outlook add-in be tested on a remote machine without registry entries?

I've written solution that consists of outlook 2010 add-in which will serialize an email and moves it to a folder where the server app detects, deserializes it and takes over.
We're getting ready to do some preliminary testing on a remote machine that doesn't have Visual Studio installed
For the server app, I know I can avoid registering the dll's by making sure that they're are in the server executable directory...
Is there anyway, we can avoid messing with the registry for the outlook plug-in, to get this initial testing done. According to this: http://msdn.microsoft.com/en-us/library/vstudio/bb386106(v=vs.100).aspx "You must create a specific set of registry entries when you deploy add-ins"
Are there any tricks to get around this?
Thanks
No, Outlook reads the class name of your addin from the Outlook\Addins key in the registry, then uses that class name to create an instance of the COM object representing your addin.
There is no way to force Outlook to do anything else.

Open Microsoft Outlook from winforms C# (.net 3.5) application in reply mode

I open outlook from my Winfoms application. I want to open outlook in reply mode. How can I do this.
Thanks.
so you want to open outlook and have it ready to send an email to a prefered receiver.
the quick and dirty fix i think is to have a hidden webbrower in your program and let the browser navigate to mailto:mail#mail.com?subject=somekindsubject
which will open the default email client on the machine.
System.Diagnostics.Process.Start("mailto:youremailaddress#whatever.com");
The mailto can be used with a lot of parameters
Check out the parameters here
http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx
http://www.ietf.org/rfc/rfc2368.txt
Eg (Taken from MSDN)
mailto:user#example.com?subject=MessageTitle&body=MessageContent
UPDATE:
Attachments i think are not supported due to security reasons and I strongly agree with it as well.
However Outlook 2003 seems to be accepting the parameter "attachments" according to someone who has posted in MSDN.
string email = "mailto:name#domain.com?attachments=\"\"C:\\file.txt\"\"";
System.Diagnostics.Process.Start(email);
This is the best i could do and i cannot test it as I do not have Outlook 2003. But even if it works in Outlook 2003, i strongly urge you not to use the attachment parameter as it may not be supported by different programs.
You can use something like:
System.Diagnostics.Process.Start("mailto:mail#address.com?subject=Sample subject");
Which will open the default email application filling in the to and subject fields. You can find more options here.
Edit: this takes a bit of time on my system, so make sure that if your user has a slower computer they'll know what's going on. Also, you should handle the case when they don't have Outlook or another mail program installed if it's a possibility.

Deploying default settings for different customers

My question is sort of linked to this existing question
How to deploy a desktop .Net application with custom settings per user
However, I understand the idea of using Application Settings what I can't find information on is, how should I deploy the application settings for different customers?
We have a custom settings system that works just fine, however when the app is first run it needs to know a couple of things, such as Company Name and Application Server. These will obviously differ on a customer basis.
I don't want the user to have to input these settings at first run as in most cases the app will be deployed by Group Policy.
Currently my thinking is to have some sort of setting file in a separate build per customer. Is this the way to go, or have I missed some kind of native support for this idea of "customer profiles"?
EDIT:
More info that might help people grok my question.
This is an enterprise application that consists of a central database and application server, plus 100 installations of a client application. I need to be able to give the client application some application settings that will obviously be different for different customers.
A lot of applications ask you some initial settings at the first start (Microsoft Office, Visual Studio, etc.). So this behaviour is commonly known by the user.
Maybe the problem is more, that these initial settings revive an update of your application. To accomplish this you could save your data in a version independent path within the registry or somewhere below %AppData%.
Also it would be helpful to prefill these dialogs at the first startup, by getting these informations somewhere out of the machine (e.g. Company Name can be get from registry [HKLM\Software\Microsoft\WindowsNT\CurrentVersion\RegisteredOrganization] or as Application Server take the Gateway address, AD Server, whatever most commonly matches).
So in a best case the user will be presented with a already correct filled out form and just has to press enter or he makes only the changes that are necessary, but doesn't to fill out the complete dialog by himself.
Update:
So if the user doesn't know the Application Server path. Who does it? Where resides this information? Maybe you can enforce your customers to provide this information all the same way. Maybe they set some environment variable within the logon script or they put a file with the needed informations on a global accessible place (e.g. where the logon script resides).
If I understand right you want to deploy a pre-customized software for each user.
You could use WIX to create a MSI-package for each customer. You can deliver several user-settings in your customer-oriented msi. You can dynamically generate a WIX-XML-Document based on a data-source where you store your customers.
Is a bit work, but later saves a lot of work. The MSI-creation through WIX can be easily integrated into the build-process.
Given that it's an enterprise environment, have you considered using ClickOnce? We've had success mainly with startup arguments, e.g. http://servername/OurApp.application?environment=uat
It doesn't always scale, but you can pass arguments using GET variables and parsing the resulting QueryString when delivering via HTTP - http://msdn.microsoft.com/en-us/library/ms172242.aspx
You might pass in the settings in the QueryString, or create them in the database, generate a (hashed?) key and build a QueryString unique to that reference (with the added benefit that an inquisitive user wouldn't be able to manipulate the URI and fake a different set of parameters).

Categories

Resources