Category Archives: Office
When developing add-ins for Office you are often serving the add-in from a local web server on a URL using the host name “localhost”. Office add-ins also require the web server to use SSL to serve the resources for the add-in. The Chrome security implementation will fire off a security error under most common development scenarios. This is when the domain of the SSL certificate does not match “localhost”.
You will see this problem manifest itself by causing your add-in to not start and show an error stating:
“Add-in Error Something went wrong and we couldn’t start this add-in. Please try again later or contact your system administrator”
If you have the Developer Tools window open in Chrome you will see error messages getting output with the text:
There is a relatively easy workaround to this problem that you can implement on your development machine to allow Chrome to bypass this certificate check on URLs served from “localhost”.
Type the following into the Chrome browser URL bar:
Enable the option:
“Allow invalid certificates for resources loaded from localhost. Mac, Windows, Linux, Chrome OS, Android
Allows requests to localhost over HTTPS even when an invalid certificate is presented.”
After making this change you will need to restart Chrome.
I was recently working on extracting mail from Outlook to an .msg file and later importing the .msg file back into Outlook. I was concerned that some of the non-obvious properties (there are a lot of non-visible MAPI properties stored on an email) would not be persisted or may change value in the process of the export/import. I thought this was going to be a daunting and time consuming process comparing the value of around 100 MAPI properties and playing spot the difference. Luckily the first thing I tried was the awesome OutlookSpy tool which I’ve found simply brilliant for assisting with Outlook development over the years. What I didn’t realise was that OutlookSpy has a build-in compare feature that will compare the MAPI properties of 2 mail items and highlight:
- Properties missing/extra on the 2 objects being compared
- Properties with different values on the on the 2 objects being compared
- Properties with the same values on the on the 2 objects being compared
Steps compare the properties on 2 email messages using OutlookSpy
Select one of the emails to compare and select OutlookSpy | IMessage
The IMessage window will appear showing all the MAPI properties on the item. From here select the Compare tab.
In order to compare this email against another email, the compare tab gives you a green area where you can drag and drop the PR_ENTRYID property from a different email message. So to do this leave the IMEssage window open on the compare tab.
Go and select the email you want to compare to in Outlook and select the OutlookSpy | IMessage button for this new email. You will be presented with the IMessage window and shown the MAPI properties for the new email. Locate the PR_ENTRYID MAPI property in the table (hint: click the column header to sort the table). Now drag and drop the PR_ENTRYID row from the table into the green drag/drop zone on the original IMessage window that you left open.
Now the magic happens! The compare tab does a comparison of the 2 items and allows you to switch between properties with the same values, properties with different values, and missing or extra properties.
I needed to find a way to export a number of pages from a OneNote notebook into Word documents. The technique I used and will step through in this post was to:
- Create a new OneNote section (temporarily in needed) to arrange the pages I wanted to export (one section per Word document I wanted)
- Export the entire section into a Word (*.docx) file
- Automatically fix up image sizing issues with a custom macro
Right-click on the section tab and select Export…
Change the export file type to be a Word document (*.docx)
This will export all pages from the OneNote section and append them all into one Word document. This is a pretty good result except for the pictures. In many cases the pictures are wider than the page width and look half missing.
The solution to quickly and easily address the image width problem in bulk is to create a Word macro to resize all images in a Word document that are too wide to fit on the page.
Here’s how we create the Word macro (this is in Outlook 2016)
The Developer toolbar needed for creating macros isn’t visible by default so to switch it on to File | Options | Customize Ribbon and ensure Developer is checked
You should now get the Developer toolbar appearing
Select Macros, give the new macro a name and select a scope for where to save the macro (this determines where it will be available later on).
You will now be dropped into the VB Macro Editor experience which looks nothing like Word! Don’t worry you just need to paste the following code in as shown
Here’s the macro code to copy/paste
Dim i As Long With ActiveDocument For i = 1 To .InlineShapes.Count If PointsToCentimeters(.InlineShapes(i).Width) > 15 Then With .InlineShapes(i) .LockAspectRatio = msoTrue .Width = CentimetersToPoints(15) End With End If Next i End With
The result should look like this, you can then save and close the macro editor window
Now back in Word, with your document open (with the oversized images) select Developer | Macros, select your new macro and click Run
Once the macro has completed all the images that were over 15cm in width will have been resized to fit on the page.
This assumes the pages are in portrait orientation and that the maximum width of an image should be 15cm
When working with Outlook for Mac the content of email messages are rendered in a web browser control that is specific to Outlook (it does not use Safari). So when you have a need to clear any cached data or cookies it is far from obvious how you should go about clearing this cache. I’m a newbie to Mac so maybe this is obvious to seasoned users! Here’s how I went about it.
- Start the Finder application
- Open the Go menu
- You need to get to the hidden Library folder. To get the Library folder to show up under the go menu, hold down the option button on your keyboard
- Now open the Library folder
- Find the Containers folder under Library and expand it
- You should be able to find a folder called com.Microsoft.OsfWebHost
- To clear out the web browser cache I move the following to the trash:
- com.Microsoft.OsfWebHost/Library/Caches/com.Microsoft.OsfWebHost (folder)
- com.Microsoft.OsfWebHost/Library/Caches/Cookies/Cookies.binarycookies (file)
Restart Outlook and you should now have no cached files being used.
Microsoft is currently running a Hack Productivity competition for creating apps that leverage Office 365 Add-ins and/or APIs to deliver an app that increases user productivity.
I’ve been working with the awesome dev team at OnePlace Solutions to cook up a modern Outlook Add-in that will run on any device and allow a user to quickly and easily save email and/or attachments from Outlook to SharePoint/Office 365 Groups.
We think it’s an awesome productivity app as it makes use of the “dead-time” you get during the day when you haven’t got time to do any heavy work but have your phone or tablet handy. This allows you to do those tasks like filing emails into your Project Management System in SharePoint while catching the train to work, or saving that updated document you’ve been sent into your Legal Matter Management System in SharePoint while waiting for your doctor’s appointment.
We are using all the cool technologies to make the magic happen. Running as a super fast Angular 2 Outlook Add-in and looking very slick thanks to the Office UI Fabric! We are utilizing the Microsoft Graph, SharePoint and Exchange services of Office 365 and hosting the app 100% on Microsoft’s Azure Cloud.
We didn’t just cobble together an app for the Hackathon, we built this app to be ready for the prime time and it will become a commercial product offering in the very near future. We have released the app into the Office Store as a preview where you can take a look at what we’ve built and try it out for yourself.
Get the OnePlaceMail for SharePoint Online preview app from the Office Store today.
Learn more about the app by visiting the OnePlace Solutions website
OnePlace Solutions is proud to be an exhibitor and sponsor again this year at the Microsoft Ignite conference in Atlanta. Ignite is Microsoft’s premier conference this year for Office 365, SharePoint, Exchange, Azure, Windows and related technologies.
I’ll be on the OnePlace Solution booth (#563) during the conference talking about our suite of products that bring SharePoint and Office 365 to where you work such as Outlook, Word, Excel, PowerPoint, Adobe Acrobat, and Windows Desktop.
I’m very excited to be unveiling our latest product OnePlaceConnect at the conference. OnePlaceConnect is focused on bringing cloud based solutions such as Office 365 and SharePoint directly into the applications you use, on whatever device you use them (yes that means on your iPad/Android tablets, phones, Mac and of course your Windows devices).
Registration is now open to participate in the OnePlaceConnect Preview and be one of the first to get your hands on the new product.
The following are some really useful resources that I often refer people to at conferences.
OnePlaceLive – Scenarios Unleashed (Project Management, Legal Matter Management)
It’s always fun meeting new people at conferences and hearing of successes, challenges and battle wounds you’ve had with technology. It’s also awesome to catch up with existing customers and partners while I’m in the US as well, so please drop by the OnePlace Solutions booth if you get a chance.
We will have some swag at the booth, and we have new and improved hacky sacks/footbags/juggling balls to give away this conference. I’m more excited than I probably should be about those!
Have a great conference and hope to see you at the booth or one of the many events.
Reach out to me @CameronDwyer on Twitter during the conference.
When developing Office Add-ins and using Typescript, I’ve found the Office.js Typescript definition file available at DefinatelyTyped to only support a fraction of the objects and properties that are available within the Office.js library.
To give you an idea of what I mean, here is a list of properties that are available on the Office.context.mailbox.item object (according to the API documentation in the Outlook Dev Center)
And here are all the properties of that same object using the Typescript definition file:
I was left wondering where the rest of the properties were. They simply don’t exist in the Typescript definition file. So this leaves us in a bit of a bind, because we are using Typescript we can’t just reference a property that doesn’t exist in the Typescript definition file (even though we know the property will exist at run-time). The Typescript compiler will do it’s job well and throw up a compile time error that the property does not exist.
Without going to the effort of taking the Office.js Typescript definition file and extending it yourself to start filling it out you may want to consider the following work around.
We can declare an object in Typescript without a specific type by specifying it’s type as any. If we do this to an object within the Office.js library we can get an un-typed handle to the object. As the object in now un-typed, we can call any property of that object we like (whether it exists or not). Below is the code that will give us access to the subject of the email that is not available in the Typescript definition file.
If the property exists at runtime then great, if not then we will get a run-time error. It is definitely a step backwards and is why we use Typescript in the first place!
It would get a bit unwieldy if you used this technique throughout your code, and I’d like to think that as we get updated Office.js Typescript definition files that we can remove this type of code from our project and access the properties in a properly typed way. To isolate your use of this technique to a central location and facilitate removing the code later on, I’d suggest creating a class that takes in the object (e.g. Office.context.mailbox.item) then inside the class it gets the un-typed handle to the item and provides methods or properties that return the missing properties (with the bonus that the values returned can have a type associated with them). Below is an example of a class with static methods that provide typed access to missing properties on a mailbox item.
Hopefully the Office team will see the value in publishing current and complete Typescript definition files so we don’t have to write code like this in future.
I have simple Angular 2 Office Addin and attempting to use the Angular 2 Router to route between two components. My two components are called ViewOne and ViewTwo.
Here’s what the UI for the Office Addin looks like:
The error message text is:
EXCEPTION: Error: Uncaught (in promise): TypeError: this_history.pushState is not a function
The same page displays without any error if it is not running as an Office Addin (rather if I just run the same router code on a standalone web page).
My best guess is that this error is due to the Office Addin framework and the fact that the Angular 2 app is running inside a sandbox iframe. I have tried running the same Angular app in a sandbox iframe on an otherwise generic html page however and I can’t reproduce the error so I think it is unique to something within the Office Addin framework.
This particular error has to do with the Angular 2 app trying to push the URL change to the web browsers history (to support back/forward navigation). In an Office Addin this doesn’t really make much sense as the Addin isn’t in control of the whole page so we wouldn’t want the Addin taking over the browsers URL history anyway.
In order to stop the Angular 2 router trying to make this call to the browser you can use a custom location strategy. In my case I was already using the HashLocationStrategy (rather than the default HTML5 routing strategy).
I went to the Angular 2 GitHub repo and found the source code for the HashLocationStrategy and created a new class in my Angular 2 app called CustomHashLocationStrategy. I just dumped all the source code into the new file, changed the name of the class and removed the two lines of code that try to update the web browsers history as shown below.
Now when bootstrapping my Angular 2 app I use my new CustomHashLocationStrategy instead of the HashLocationStrategy. Here’s what that change looks like in code.
Before (click for full size image):
After (click for full size image):
After this change I can now navigate between the 2 routes without any errors being thrown to the console.
The code shown in this article in the Angular 2 Router in RC1. I also had the same issue using the “Router-Deprecated” in RC1, the same solutions worked for me using the deprecated router.
I also tested that this fix worked across Chrome, IE, Edge and Windows Desktop Office Client.
I’m preparing to head down to Melbourne for the The Digital Workplace Conference (the new Australian SharePoint Conference). This will be the first conference since the 7.3 release of OnePlaceMail and OnePlaceLive. I’m pretty excited about the new Email Tracking features which goes well beyond simply allowing users to transfer email and attachment from Outlook to SharePoint. This goes to a whole new level. Save an email to SharePoint (or Office 365) and all other recipients of the email can see in real time that you have file it to SharePoint and can open up the location in SharePoint. No more having multiple people trying the file the same email to SharePoint to find that someone has already save it there. Or worse, people saving it to different locations in SharePoint and having the files duplicated.
If you haven’t checked out the OnePlace Solutions suite in the last few months you may have also missed the suggested and predictive email filing capabilities that analyze the filing patterns of users and will suggest or predict locations in SharePoint that are likely locations you would want to save the email. If you’re not going to make it to see us at the Melbourne conference (or simply can’t wait that long to see what I’m talking about) here’s a short video on the Email Tracking feature. See for yourself how just one feature can make the Digital Workplace so much easier for a user, then imagine a whole suite of products packed with features like this, then come and see me at the conference!