PDA

View Full Version : Handling MIME in JSON



mjhaston
23 Sep 2011, 8:36 AM
I can't for the life of me figure out how to return MIME in JSON. I keep getting unterminated string literal. Does anyone have a suggestion or example of how to return MIME to an xtype: 'htmleditor' ??

Uberdude
26 Sep 2011, 6:34 AM
What exactly do you mean by MIME? (I mean what are you trying to do, I know what the letters stand for!)

mjhaston
26 Sep 2011, 6:50 AM
I have a grid displaying my POP3 email account. When I click on a row I want to open a window displaying the email. These email files are stored on my AS/400 system as .MHTML files that contain the MIME.

I was able to display the file itself using the src keyword and a direct url. This displays the MIME code itself and is not interpreted by the window/form. Makes sense.

So I'm thinking I need to display this code in an 'htmleditor' field so that it displays correctly, like it does in a browser. My attempt to do this was by returning the code in a variable in a JSON string. This falls apart at the first line break. The MIME in the file on my system is multiple rows. I may need to try and "smooch" all of the MIME into one long string with no line breaks.

Did I make this more confusing?

Is there a way to load a htmleditor from a file by setting a url or src?

mjhaston
26 Sep 2011, 7:12 AM
As an example, here is my JSON. I get the error message in Firebug that states "unterminated string literal". It looks like after the first line before "Envelope":



{ "success" : true, "data" : { "id":"1", "emailBody" : "Return-path: <[email protected]>
Envelope-to: [email protected]
Delivery-date: Mon, 26 Sep 2011 11:04:55 -0400
Received: from notprovisioned.tchmachines.com ([127.0.0.1] helo=xxxxxxx)
by xx.xx.com with esmtpa (Exim 4.69)
(envelope-from <[email protected]>)
id 1RCjn-000jQ-EX
for [email protected]; Mon, 26 Sep 2011 11:04:55 -0400
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary=&quot=_43bccc713e78810faf57adf49b0&quot
Date: Mon, 26 Sep 2011 11:04:55 -0400
From: [email protected]
To: Michael <[email protected]>
Subject: test subject
Message-ID: <[email protected]>
X-Sender: [email protected]
User-Agent: Roundcube Webmail/0.5.4

--=_43bccc713e78810faf1a75657adf49b0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=UTF-8



test CONTENT
--=_43bccc713e78810faf1a75657adf49b0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<!DOC"}}

mjhaston
29 Sep 2011, 11:22 AM
I've made some headway. My file displays in the window panel and some of the HTML actually renders. All of the MIME code is ugly! I kind of thought it would show up the way it does when I open the MHTML file with a browser.







xtype : 'actioncolumn',
width : 30,
items : [{
//icon : '../icons/email.png',
//tooltip : 'Click to view email',

getClass : function(v, meta, rec) {

if (rec.get('status') == '1') {
// this.items[0].tooltip = 'Report has been sent';
return 'emailOpenedCss';
} else if (rec.get('status') == '2') {
// this.items[0].tooltip = 'Report is available to send';
return 'emailClosedCss';
} else {
return 'emptyCss';
}
},
handler : function(grid, rowIndex, colIndex) {
var rec = wrklnkStore.getAt(rowIndex);

var w2 = new Ext.Window({
id : 'w2panel',
width : 600,
height : 600,
closeAction : 'close',
autoScroll : false,
modal : false,
title : "Contents of email:",
items : [{
xtype : 'panel',
// height : 100,
autoHeight : true,
// title : 'Header',
html : 'From: '
+ rec.get('from') + ' < ' + rec.get('fromAddress') + ' >'
+ '<br />To: [email protected]'
+ '<br />Subject: ' + rec.get('subject'),
padding : 5
}, {
// xtype : 'panel',
layout : 'fit',
cls : 'contentIframe',
autoEl : {
tag : 'iframe',
height : '100%',
width : '100%',
id : this.iframeId,
src : "../../../../"
+ rec.get('path') + "/"
+ rec.get('filename'),
html : "../../../../"
+ rec.get('path') + "/"
+ rec.get('filename')
}
}]
})
w2.show();
w2.setTitle(rec.get('subject'));
}
}]