Cyrillic characters are corrupted when using body.getAsync - outlook

I've developed a simple task pane add-in for testing Cyrillic characters, but when using body.getAsync() the Cyrillic characters appear to be encoding incorrectly.
Is there a workaround for getting Cyrillic html from an email body? Here’s the code I’m using:
var message = Office.context.mailbox.item;
message.body.getAsync(Office.CoercionType.Html, function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
$("#gridResult").html(result.value);
}
});
Here’s the result I get. All the Cyrillic characters are messed up.
Edit
I ran the code through the Visual Studio debugger and set a break point on the result.value prior to invoking .html(). The corrupted values are visible. The same thing happens when attaching to the IE Process using F12 developer tools:

This has been discovered to be a bug. It will be fixed in an upcoming update for C2R builds. Tentatively, if the build is AFTER 16.0.7117.1000, it should be fixed. This build number is not the exact number that will come up, but when a update comes out, if the number is AFTER that build, the fix should be in.
I can't confirm that this fix will make it until the actual patch comes out though.
The fixes for MSI Outlook 2016 and MSI Outlook 2013 will come afterward. I will update with the KB's and Patches for those updates once they are scheduled to be released.

Thanks for reporting this issue. It was a regression in Outlook Desktop and the fix will get to clients in about two months.
In the meantime the workarounds are calling the API with Office.CoercionType.Text
var message = Office.context.mailbox.item;
message.body.getAsync(Office.CoercionType.Text, function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
$("#gridResult").html(result.value);
}
});
Or using your addin in OWA (Outlook on Web).

Related

Problem opening Office URI Scheme urls in Office.js on Mac/Safari

I'm developing a JavaScript addin for Office applications, e.g. Word, Excel and PowerPoint. At some point it should open a file that resides somewhere in SharePoint.
I want the url to open the correct Office application right away and for this purpose I'm using Office URI Schemes (see https://learn.microsoft.com/en-us/office/client-developer/office-uri-schemes?redirectedfrom=MSDN).
Depending on the logic in the app, I'm using two different techniques, which work perfectly when the addin is running in Word, Excel or PowerPoint on Windows.
Technique 1 (normal link)
Open Me!
Technique 2 (programmatic)
// Js pseudo code
button.onclick = () => {
window.location = 'ms-word:ofe|u|https://foo.sharepoint.com/path/to/file.docx'
}
As I mentioned, both these techniques works flawlessly on Windows. But when running the addin on e.g. Word Desktop on Mac, absolutely nothing happens. I've debugged the addin, by using "Inspect Element" to open up the console, but there's no errors or anything. It seems to me that the internal browser on Mac silently refuses to open the link.
However, if you paste the link into e.g. a word document, it will open the document if clicked.
Some thoughts:
is this related to the manifest.xml for the addin? (still works on windows without modifying the manifest)
do I need to enable something on Mac for this to work? (the Office URI Scheme page states these links should work on Office for Mac 2011)
Any input is greatly appreciated.
I found a workaround that works on Mac as well by using window.open(url).

PowerPoint content app crashes in PPT online sometime during a saveAsync call

I have a PowerPoint content app that runs well in the desktop version of PowerPoint 2013 and 2016, but in PowerPoint Online it crashes (I believe) sometime during the execution of Office.context.document.settings.saveAsync() with this error:
I've traced it through this code:
var saveSelected = function (selected) {
if (Office.context && Office.context.document) {
Office.context.document.settings.set("selected", selected);
Office.context.document.settings.saveAsync();
}
else {
localStorage.setItem("selected", JSON.stringify(selected));
}
}
and can see the code run through this block as well as pop out of it to the parent function and finish execution, but a moment later it crashes and on a reload the setting hasn't been saved, so I'm assuming the crash happens somewhere inside the asynchronous save. The data I'm trying to save is an object that looks something like this:
{
siteUrl: "https://modtenant160315b.sharepoint.com",
type: "chart",
url:"/drives('b%21H9_EgioNdUWL9Etpw0KgzkCIo4W1XPBCt7YkrAyP0lx8OUvBlEQvQ52j2Fg2P-a0')/items('01DLGLVOTPCNS67WMCPBG22JL3VR4SOUWE')/workbook/worksheets(%27%7B00000000-0001-0000-0400-000000000000%7D%27)/charts(%27%7B00000000-0008-0000-0400-000002000000%7D%27)"
}
Any thoughts?
edit: I just added this to my app's landing page and it also causes the crash in PPT online, so it doesn't seem to take much:
Office.context.document.settings.set("dummySetting", "this is my setting");
Office.context.document.settings.saveAsync(function () {
var x = Office.context.document.settings.get("dummySetting");
$scope.sharepointUrl = x;
});
Turns out it was due to an outdated Office.js file. Switching from a local version to a hosted copy resolved the crash.

Visual Studio ASP.NET crashes after Stop Debug in Chrome

I'm working on a website which can stream audio files to the browser. It's a asp.net application which im developing in Visual Studio 2013. To stream the audio to the client im using partial content response using the range request headers. The code looks like this:
[HttpGet, ActionName("GetFile")]
public HttpResponseMessage GetFile(string fileName)
{
var rootPath = AppDomain.CurrentDomain.BaseDirectory;
var fullPath = Path.Combine(rootPath, "SoundFiles", fileName);
byte[] file = File.ReadAllBytes(fullPath);
var mediaType = MediaTypeHeaderValue.Parse("audio/mpeg");
var memStream = new MemoryStream(file);
if (Request.Headers.Range != null)
{
try
{
var partialResponse = Request.CreateResponse(HttpStatusCode.PartialContent);
partialResponse.Content = new ByteRangeStreamContent(memStream, Request.Headers.Range, mediaType);
return partialResponse;
}
catch (InvalidByteRangeException invalidByteRangeException)
{
return Request.CreateErrorResponse(invalidByteRangeException);
}
}
else
{
var fullResponse = Request.CreateResponse(HttpStatusCode.OK);
fullResponse.Content = new StreamContent(memStream);
fullResponse.Content.Headers.ContentType = mediaType;
return fullResponse;
}
}
Every time a song is played this method is called to get the file from the server and to stream it partially to the client. The whole application is built with signalr.
This worked perfectly for me there is nothing wrong with that code. Until i bought a new pc. I installed my Visual Studio 2013 normally on it including IIS Express 8.0 etc. But something strange happened to this.
If I start debugging with Google Chrome, and then if I do normal things to the website but not playing a song (not calling the method), and then stop debugging it again I have no problems. But if I start it in Chrome and play the song (call the method) and then try to stop debugging, visual studio freezes but there is no information that it is hanging. Its just hanging and I cannot close it. I cant even close it with the task manager. No error is showed. If I try to shut down my pc, then the pc won't shut down until I press the power button a long time. Now the strange thing: If I try the exact same thing but in Internet Explorer, Visual Studio works normally and is not hanging at all. This only happens if I use Chrome for debug and only on the same host as Visual studio is running. If I connect a Chrome on a other Device in my network, it does not have any effect.
I figured out, that I can run the application without debugging. If I do that it works good, but if I play a song and then try to close Visual Studio, it shortly hangs for about 30 seconds and then quits.
I am unable to find out what the problem is.
What I already tried to do:
Reinstall Visual Studio 2013
Try with Visual Studio 2015, same effect
Reinstall Windows 8.1
Reset Import/Export Settings in Visual Studio
Run Visual Studio as Administrator
Move SoundFiles to an other directory
Try with Google Chrome Canary, same effect
And the really strange thing is, that it only happens on Chrome on the same machine, and only on my new pc. The same scenario works perfectly on my surface or on the old laptop.
What I could imagin, for the chrome reason is, that chrome uses range requests and ie does not. It takes the full Response of audio as 200 and chrome takes the range as partial content. This could be the problem, but I'm not sure and I don't know how to solve or workaround this problem.
Have you guys an idea, what could causing this problem?
Ok, I didn't manage to find the problem, but I found the solution. Because it was a new PC, there was little bit of bloatware on it. I've uninstalled the things I don't needed, and then it magically worked. No crashes anymore. I have a ASUS ROG G20AJ. I don't know exactly which of the bloatware was causing the problem, but it was some of them. So if you have a similar problem on a ASUS Machine, try uninstalling some of the not used software.
It wasn't Visual Studio crashing, it was the IIS Service. I really think that this is a really strange behaviour, because the crashes did only happen, if I executed the code snippet above... Anyways, it works now!

Outlook addin has failed to find Office control by ID

I've just built an MS Outlook Add In using Visual Studio and Office 2010. I've installed it ok on 4 machines, but one user is getting the following error -
Error found in Custom UI XML of "...."
...
...
Failed to find Office control by ID
Everyone is running Windows 7 and Outlook 2010 - not sure why this person is having a problem. Can anyone suggest how to diagnose this?
For those having similar issues, you don't have to remove any add-in.
What is happening is: Outlook will try to load all ribbons (found in your ribbon xml) into any window the user goes to. Then it'll complain about not finding ID x or y.
Just make sure your GetCustomUI method in Ribbon.cs does not load the entire ribbon XML at once but rather loads it per fragment.
If you're not sure what IDs you need to target, use a breakpoint in GetCustomUI then start Outlook, surf different views (main, new email, new appointment, calendar...etc) in order to gather the IDs for the views wherein you need to show you add-in.
In my case, I needed Microsoft.Outlook.Explorer, Microsoft.Outlook.Mail.Compose and Microsoft.Outlook.Appointment.
Therefore I changed my GetCustomUI to:
public string GetCustomUI(string ribbonID)
{
switch (ribbonID)
{
case "Microsoft.Outlook.Explorer":
return GetResourceText("MyAddin.RibbonsForOutlookExplorer.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("MyAddin.RibbonForOutlookMailCompose.xml");
case "Microsoft.Outlook.Appointment":
return GetResourceText("MyAddin.RibbonForOutlookAppointment.xml");
default:
return null;
}
}
Of course, I had to break down my Ribbon.xml into the three XML files mentioned above. The result: Outlook will ONLY load the fragment needed for a given screen (appointment, new email ...) and will not complain about "not finding an ID on screen X or Y".
Finally, for those who are not sure why some users get that error while others don't: it's because of "Show add-in user interface errors" option (in Options -> Advanced). If that is unchecked then Outlook will ignore the malformed ribbon XML errors. If it checked, users will get related errors about your add-in (if any exists) and also about other add-ins.
If it works for everyone except one user. As #Brijesh Mishra mentioned check if the user has got any other addin and if he is having own quick access tool bar customized.
If he has got any of this then, remove the other addins and try to install or reset the quick access tool bar customization.
For all of you that use a Designer-based VSTO plugin, and not the XML solution.
I searched all the web for this problem, but only found XML-based solutions.
There's nothing for Visual Designer on the web, because in this case you don't have to override the "GetCustomUI" method.
Ribbons designed by using the Visual Designer return a RibbonManager by default.
This RibbonManager object represents all Ribbon (Visual Designer) items in the project and is automatically handled in background through the active window inspector.
So you don't have to write any special code to handle different windows.
To configure it correctly you just have to:
Add one extra Visual Designer Ribbon for every window the user goes to
in the Ribbon Object go under "RibbonType", open the checkbox list an only activate the corresponding window, where the ribbon should appear.
If there is more than one window checked in the list, Outlook trys to insert the ribbon in all the marked windows. Even if the corresponding window is currently not opened. That's the reason, why the error "Failed to find control ID" appears.
the actual fix for me was to separate the ribbon XML files containing the customUI and redirecting to the correct one in the GetCustomUI method (implemented using Office.IRibbonExtensibility)
in example:
public string GetCustomUI(string RibbonID)
{
switch (RibbonID)
{
case "Microsoft.Outlook.Mail.Read":
return GetResourceText("namespace.type1.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("namespace.type2.xml");
default:
return null;
}
}

Track issue-related comments like "// fixes #123" in Visual Studio, similar to task list

We use an issue tracker (Redmine) for our software tasks/bugs and often mark the fixes/implementations with a comment like this:
// fixes #1234: changed this and that
Or we also mark code locations which cause a certain bug like this:
// causes #2345
Now, I am looking for a tool which can automatically track those issue-related comments in all files in the current solution and present them in a list or tree. This is similar to the task list which scans the files for comments with // TODO or // HACK. Unfortunately, it is not possible to define a new task category with just # as identifier because this character is not allowed.
Does anyone know of such a functionality, addon, or tool for VS2010 or VS2008?
This is generally a feature provided by whatever issue tracking software you use rather than a function of Visual Studio. Codebase HQ for example scans code (on commit) for speciially formatted comments that it is configured to recognise and groups the code change/commit to the record of the issue. It's web-based.
Axosoft OnTime provide a plugin for Visual Studio which allow you to work with your issues directly within the IDE.
See: http://www.axosoft.com/ontime/visual_studio_plugin
Failing that, if you only want to track bug causes between commits while you're working, then the inbuild tracker might be of use after all...
Add a tag to track with to Visual Studios configuration (I've added the CausesBug token)...
Then add the token in amongst your code:
public override bool IsApproved {
get
{
// CausesBug: 1234
return this.IsEnabled;
}
set { this.IsEnabled = value; }
}
Then each item gets listed in the Task List, displaying location in source, until you can ammend, and then say you fixed the issue in your commit, in turn getting picked up by your issue tracker.

Resources