Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

xrm.navigation.openfile doesn't work in Internet Explorer or Edge Legacy

$
0
0

Hello,

Setup: Dynamics 365 CRM v9 on-prem, logged in as Sys Admin

I have a javascript web resource on an entity form that generates a .EML file. This file is then opened via the Xrm.Navigation.OpenFile() method. I am using the default Web UI.

In Chrome it downloads the file fine and when I open it it will open in an outlook window and show everything (To,CC,Subject, Body[HTML] and Attachment). I noticed that the file is encoded in ANSI by default.

In IE 11 or Edge Legacy, however, it fails to download and generates the folllowing error: The URI to be decoded is not a valid encoding. I fiddled with the .EML and replaced the HTML Body with something simple and it does download but I noticed the encoding is Unicode. If I try to open this file it will show up in an Outlook window but is blank. If I save the file in notepad with a different encoding like ANSI or UTF8 it then opens fine with Outlook.

I have been trying to find javascript code to change the encoding of my .EML string to UTF-8 before calling open File but haven't found anything.

The code is something along the lines of:

// attachment details retrieved via a webApi call
var documentbody = results.entities[0]["documentbody"];
var filename = results.entities[0]["filename"];
var mimetype = results.entities[0]["mimetype"];

var testEML = "To: " + toAddresses + "\r\n";
testEML += "CC: " + ccAddress + "\r\n";
testEML += "Subject: " + subject + "\r\n";
testEML += "X-Unsent: 1\r\n";
testEML += "Content-Type: multipart/mixed; boundary=boundary_text_string\r\n";
testEML += "\r\n";
testEML += "--boundary_text_string\r\n";
testEML += "Content-Type: text/html; charset=Windows-1252\r\n";
testEML += "\r\n";
testEML += "<html><body>HELLO WORLD!</body></html>" + "\r\n";
testEML += "\r\n";
testEML += "--boundary_text_string\r\n";
testEML += "Content-Type: " + mimetype + "; name=" + filename + "\r\n";
testEML += "Content-Transfer-Encoding: base64\r\n";
testEML += "Content-Disposition: attachment\r\n";
testEML += "\r\n";
testEML += documentbody + "\r\n";
testEML += "\r\n";
testEML += "--boundary_text_string--";

// Step 5: Show EML File (which will open an outlook email window ready to be sent)
file = {};
file.fileContent = btoa(testEML);
file.fileName = "notice-" + fieldMappings.TrackingNumber + ".eml";
file.mimeType = "message/rfc822"; // EML standard - tried adding charset="UTF-8" but didn't do anything

parent.Xrm.Navigation.openFile(file).then(function (success)
{
console.log("File downloaded successfully.");
}, function (error)
{
// does not work in Edge or IE (The URI to be decoded is not a valid encoding)
console.log("File was not downloaded.");
console.log(error.message);
});

 Any ideas? Currently I just tell users to use Chrome... but I would like it to work with IE and Edge. 

Thanks,


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>