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

CRM 2016 eMail Attachment

$
0
0

I have spent 2 weeks trying to attach a PDF to an email with no success.  I know I am missing something very simple but cannot find a solution. I've tried every solution i could google no success.

Step 1 Generate the PDF from HTML - Completed

Step 2 Read/Retrieve the PDF - Completed

   var pdflocation = pdfpath + printContents + '.pdf';
    jQuery.get(pdflocation, function(data) {
            var str = base64ToArrayBuffer(data);
            console.log(btoa(str));
    });

Step 3 convert to bytearry - Fail - Fail - Fail

         function base64ToArrayBuffer(data) {  
/*
            var reader = new FileReader();
            reader.readAsArrayBuffer(data);
            var arrayBuffer = reader.result
            var bytes = new Uint8Array(arrayBuffer);
    
            //var buffer =  atob(data);
            var buffer = new ArrayBuffer( data.length );
            //var buffer = window.btoa(escape(encodeURIComponent( data )));
            //var buffer = encodeURIComponent( data );
            var len = buffer.length;
            var bytes = new Uint8Array( len );
*/
              
            var buffer = new ArrayBuffer( data.length ), // res is this.response in your case
                bytes   = new Uint8Array( buffer ),
                len    = bytes.length,
                fromCharCode = String.fromCharCode,
                i, s, str;    
            str = "";


                 for ( i = len; i--; ) {
                   bytes[i] = data[i].charCodeAt(0);
                 }

                 for ( i = 0; i < len; ++i ) {
                   str += fromCharCode( bytes[i] );
                 }    
/*
*/
/*

                 for ( i = 0; i < len; ++i ) {
                   //str += fromCharCode( data[i].charCodeAt(0) & 0xff );
                   bytes[i] += buffer.charCodeAt(i);
                 }
*/                 
            //for (var i = 0; i < len; i++)        {
              //  bytes[i] = buffer.charCodeAt(i);
            //}

            return bytes.buffer;
        }

Any and all help would be appreciated.


Viewing all articles
Browse latest Browse all 55831

Trending Articles



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