Presence integration with Outlook 2013 - c#

I am trying to integrate my IM-client, written in C#, with MS Outlook 2013. I would like Outlook to receive presence information from my IM-client. First shot was to use this instruction.
It worked well in the beginning (Outlook get my interface, check for version and features, abilities to start conversation), but in the chapter "Retrieving contact presence" I've got a difference. Outlook didn't call "GetContactInformation" as described. It isn't work for neither interface returned for version "15.0.0.0" nor "14.0.0.0".
I've tried to turn on logging using OfficePresenceLogging, but it appeared to be available only for previous versions of MS Outlook. So, I used this technique, which gave me binary file "Microsoft Support Engineer has the tools to analyze".
Since I use Windows 8.1, LorParser 2.2 unable to read this file, and TraceRpt.exe is only able to give me metadata (like time or Process ID). The important part of the log is hidden beneath BinaryEventData field. I could translate those hexes to ascii and see something like a methods names and garbage.
I wonder if someone could advise me something:
Is it possible to read Office 2013 logs to troubleshoot my IM integration?
Is there any hints that could I check to find a problem?

I come up with some solution, so I want to write down an answer. I hope it can be useful for someone.
Unfortunately I failed to read Outlook 2013 logs in both Windows 8.1 and Windows 7. The only solution I've found: test the application with Office 2010 (it uses text logs). You can find instructions how to turn on logs at the end of this article.
In my case the first error I've got was:
"CMsoProviderOCom::HrEnsureContactAndGroupManager !failed! Line: 3998 hr = 0x80040200"
It seems Outlook reject all further information if something went wrong at the beginning of the integration with IM.
Check your application returns all correct values for the methods Outlook uses.
Check you've implemented all events, it seems impossible to find lack of them with debugger.
Take a look at Lync SDK. It has the similar interface (Microsoft.Lync.Model) and it's documentation looks more complete.
In my case I just forgot to mark couple of my classes with [ComSourceInterfaces()].

Related

What are common code smells that cause Outlook 365 to permanently disable a custom VSTO COM Add-In?

I am currently maintaining a company-internal add in that only takes a mail, wraps it as attachment and sends it to our internal mail adress for spam reports.
The add in always had the issue that for seemingly no reason ( - besides: "the addin has caused outlook to crash - therefore it has been permanently disabled", when checking the addin state)
Outlook doesn't like it and disables it permanently without options to re-enable.
This was already an issue with Outlook 2016, and could back then be solved by setting a few registry keys. I was tasked to build a version for Outlook365. Outlook365 seems to be a lot more sensible there.
I have added a function that sets the following keys:
[HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\SpamReporter]
"LoadBehavior"=dword:00000003
[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Resiliency\DoNotDisableAddinList]
"SpamReporter"=dword:00000001
[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Addins\SpamReporter]
"LoadBehavior"=dword:00000003
The following key is also rolled out via company policy:
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\16.0\outlook\resiliency\addinlist]
"SpamReporter"="1"
Furthermore. The assembly is signed with a Comodo Certificate in Visual Studio, and I have also tried to sign the installer itself again.
But all of these efforts seem to not make a difference. I thought I had a working version we could roll out, only to get the response from our rollout guy that the plugin doesn't show up for him when he tested it quickly.
This behaviour is really frustrating and the docs on Office 365 VSTO COM add-in troubleshooting seem really scarce.
I have spent an obscene amount of hours trying to fix this issue.
Most likely your addin takes too long to load (assuming it does not crash on startup).
Note that you get punished for using .Net - the whole .Net run-time of a particular version needs to be loaded before a single line of code in your addin runs. There used to be a Warmup registry key that allowed to tell Outlook whcih version of .Net run-time you are using so it will preload it, but it is no longer supported.
What does Outlook itself say when you go to File | Options | Addins | COM Addins?

Where to store sensitive information needed for an application to run?

I am writing a c# winform desktop application that is in contact with a MYSQL database. Of course I cannot leave the database credentials out in the open hard-coded into the application, so where can I store this information so that a nosey customer will have an extremely tough time locating it?
I understand that if someone is very determined to find this information they will most likely do just that, but I want to be able to hide these credentials from the average Joe, leaving me with some peace of mind at the end of the day.
If your answer is to encrypt the credentials, and hard code the encrypted values into the program, please explain which encryption methods to use. Furthermore, where would I store the necessary decryption/encryption keys?
I very much look forward to some interesting responses.
Thank you,
Evan F.
http://www.ezzylearning.com/tutorial.aspx?tid=8067328
Store it in App.Config File.
Check out above tutorial.
You can also check this good article by Microsoft which teach you how to encrypt and retrieve.
http://msdn.microsoft.com/en-us/library/ms254494.aspx
One of Previous Posts
if you have installed Microsoft Enterprise Library, you can easily encrypt/decrypt using its tool as mentioned in this link
http://davidhayden.com/blog/dave/archive/2006/01/23/2744.aspx
http://davidhayden.com/blog/dave/archive/2006/03/02/2870.aspx
Also, after the installation, open the project in studio and right click on the web.config or app.config and you will see the option for the configuration though Enterprise Library. This option is available in Visual Studio 2005 but I cannot see this in Visual Studio 2008 yet. Not sure whether its not compatible with 2008 or I have to follow some installation sequences. I will let you guys know if I come across with any solutions.
This is the link which explains how to work with encryption within studio http://www.pnpguidance.net/Post/EnterpriseLibrary3VisualStudioIntegratedConfigurationEditor.aspx . Read, read & read...
Keep in mind that once you open the .config file you have luxuary of ecrypting each pieces/blocks seperately. Thats the beatuy of it.
For your information I am using Enterprise Library 3.1 which is the latest version and has tonnes of tools that makes your life a breeze. You can download this library at http://msdn2.microsoft.com/en-us/library/aa480453.aspx. Also, look forward for 4.0 at http://www.codeplex.com/entlib
Bottom line you can search google along these lines and I am sure it will give you the whole process.

How can I get data off of my Windows Phone 7 emulator

I have a unit testing framework for WP7 and it runs on the phone. The results are fairly hard to read so I am writing them to an XDocument.
My question is, how can I then get this XML file off of the phone and onto my desktop where I can actually analyze the results?
What I have done so far is to put a Debugger.Break() line right after where the summary xml is created. I can then copy/paste the xml out of VS or inspect it right in the debugger. The problem is though, that if you don't already have a debugger attached (which is good when lots of ExpectedException tests) Debugger.Attach() seems to not work, also manually attaching VS to the emulator processes seems to do nothing.
I tried running the emulator with some extra command line parameters so I could try to see if I could get it to use my actual hard drive as it's own disk but I couldn't seem to get it to work...
PS it's probably not reasonable to pop open a new process such as a webserver to listen for this data. I know how to do that, I would just rather not.
So how the heck do you get stuff off of these phones??
Have a look at this article about emulator automation from Justin Angel.
It includes details on how to remotely read and write files from/to emulator/device isolated storage.
As you pointed out the other alternative would be to have the applciation send the results to a [local] web server.
The article by Justin Angel is really great, but unfortunately his file-based solution does not work on the final RTM versions of the CoreCon API. Microsoft has simply removed that functionality from the native conman layer.
I've been in the same situation as you and have contemplated various ways to get data out of the device, but in the end only one thing seems to work: as you suggest yourself, pass data to an external webservice.
That solution is less than ideal not only because it takes some effort, but also because of a few caveats:
your app must be granted ID_CAP_NETWORKING capability
network-traffic seems disallowed in the Application_Closing event, and maybe elsewhere too
On the bright side I found that webrequests from the phone, both hardware and emulator, were really fast so the approach works very well (our app is EQATEC Profiler for WP7).

How to prepopulate an Outlook MailItem and avoiding a com Exception from the object model guard

I work for a company that develops a CRM tool and offers integration with MS Office(2003 & 2007) from windows XP to 7. (I'm working using Win7)
My task is to call an Outlook instance (using C#) from this CRM tool when the user wants to send an email and prepopulate with data of the CRM tool (email, recipient, etc..)
All of this already works just fine.
The problem I'm having is that Outlook's "object model guard" is throwing com Exception
(Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)))
the moment I try to read a protected value from the mailItem (such as mail.bodyHTML).
Example Snippet:
using MSOutlook = Microsoft.Office.Interop.Outlook;
//untrusted Instance
_outlook = new MSOutlook.Application();
MSOutlook.MailItem mail = (MSOutlook.MailItem)_outlook.CreateItem(MSOutlook.OlItemType.olMailItem);
//this where the Exception occurs
string outlookStdHTMLBody = mail.HTMLBody;
I've done quite a bit of reading and know that my Outlook Instance (derived by using new Application) is considered untrusted and therefore the "omg" kicks in.
I do have a workaround for development:
I'm running VS2010 as Administrator and if I run Outlook as Administrator as well - all is good. I suppose this is due to them having the same integrity levels(high) and the UAC(?) is not complaining. But that just ain't the way to go for deployment.
Now the question is:
Is there a way to obtain a trusted instance of Outlook so that I can avoid this exception?
I've already read that when developing an Office Add-In using VSTO one can obtain a trusted Instance from the OnComplete event and/or using "ThisAddin"
But I "merely" want to start an outlook instance and preopulate it, and do not want to develop an Add-In since this is not the requirement.
And to make it clear - I have no problem with pop ups informing the user that outlook is being accessed - I just want to get rid of the exception!
So how can I get around this problem using code?
Any help is highly appreciated!
Thomas
Take a look at Dimitry's Redemption Lib, It was designed to do exacly this.
Well,
I've already spent way too much time and energy on this question so I think I came up with a pragmatic workaround for my particular case - but no real solution!
The problem is apparently due to the programms running at different integrity levels (Outlook = medium, VS2010 = admin or high). Office runs by default on a medium level and so will my future application once deployed. So there shouldn't be any trouble, since if the CRM and Outlook run at the same level, there's no problem.
For development I just let em both run on high, or medium (starting my compiled files from the debug folder).
In any other case a Messagebox warning is shown informing the user of the different integrity levels that cause an exception and prevent access.
At the code level, when I try to read any (by Outlook) prepolutated, protected properties and the object model guard raises the exception, I just catch it and use default values instead.
Why I had to read them in first place is currently beyond me - but so were the specs which were handed to me.
Anyway thanks for reading and if I ever come up with a solution I'll be sure to psot it - until then keep in mind that a pragmatic solution is better then none!
Happy Father's Day everyone!

Spell check in winforms

In my win forms C# app, I want to be able to add spell check functionality. But, I want to do it my own way, and NOT use any other components. All I need is just an online service where I can send a request or something and it tells me whether or not the word i sent was spelled correctly.
Preferred but not required: The ability for that online service to also send back suggestions.
Personally, I wonder why you want only online access...what if you lose connection? Also, most online accesses come with restrictions.. which you might hit sooner than you think during debugging.
If you were to use WPF, I'd suggest using the SpellCheck Class.
Since you specified Windows.Forms, you might try the NetSpell library for offline access. You can also try and use Microsoft Word's spellchecker, but you might not have it installed on the machine (or use Linux & Mono)
If you persist on using online access, you can use Yahoo, as Giovanni Galbo says. It's been done in C# before.
A quick google search turned up this:
Search Web Services: Spelling Suggestion
This is not c#/.NET specific. Its a simple REST service provided by Yahoo!. It looks like they do limit you to 5,000 queries per day for free and I'm not sure if Yahoo! lets you upgrade to a pay service.

Categories

Resources