HTML mail problems with IE7

eggwise's picture

Hello, We have created some mashups that send email as HTML in the message body. The message itself is the innerHTML of an element. This works very well in IE6, FF3 and Safari. When sending mails within IE7 it doens't work, only when the message body (supposed to be in HTML) is empty. Who can help. Thx, JB

code mashup

sendmail.documentation = "Send E-mail" ; sendmail.inputTypes = {"from":"string", "to":"string", "subj":"string", "msg":"string"} sendmail.outputType = "string"; function sendmail(from, to, subj, msg) { var email = new Email(); email.from = from; email.to = to; email.subject = subj;

email.html = msg;

; email.send(); return "done"; }

igoogle widget code

function mailit(){ if (isConnected == true && ms_002de_cache != undefined && eml.value !="") { var c="<p>" + comment.value + "</p>"; var e= eml.value; var f= myeml.value; var s= subj.value +" [__MSG_q_from__ __MSG_q_debt__ widget]"; ms_002de_cache.sendmail.callback = showresponse; ms_002de_cache.sendmail.onError = handleError; ms_002de_cache.sendmail(f, e, s, c + tab1txt.innerHTML); //store the email to prefs prefs.set("email", e); prefs.set("myemail", f); // message msg.createTimerMessage("<div class='dummy' style='text-align:center; overflow:hidden'>__MSG_q_sent__ " + e +"</div>", 3); } }
keith's picture

It looks to be a problem in the way you obtain the innerHTML

If this works on IE6, IE7, FF3 and safari then we are sure that it is not an issue with your mashup and the issue is in the way you get the innerHTML in the browser itself. It as not clear as to what "tab1txt" is. Note that innerHTML does not work for all elements (on some browsers) and this could well be the issue you are facing. You can simple add an alert in the browser itself and check the value of "tab1txt.innerHTML". What is the type of the element referred to by "tab1txt"? Thanks, Keith. Blog : http://www.keith-chapman.org
eggwise's picture

Jan-Bart Bergers

Hello Keith, The tab1txt is a div <div id="tab1" class="dummy" style="display:none"></div> <div id="tab1grph"class="dummy" style="display:none"></div> <div id="tab1txt" class ="tab" style="display:none"></div> I'll focus on the innerHTML thing and keep you informed. As I understand from your reply it seems not to be a known WSO2 bug. Cheers, Jan-Bart
jonathan.wso2.com's picture

I suspect there might be two

I suspect there might be two "tab1txt" identifiers. Since only one is allowed per document, a restriction not enforced in the browser, there isn't a standard for what to do in this case and IE might be grabbing a different one (the last, instead of the first, for example). Also, for better cross-browser compatibility you might replace tab1txt.innerHTML with the standard document.getElementById("tab1txt").innerHTML.
eggwise's picture

Hi Jonathan, I just checked,

Hi Jonathan, I just checked, there is definitely one txt1txt div in the document. Your suggestion about document.getElementById("tab1txt").innerHTML I will use. The suggestion of Keith to add an alert() to show the innerHTML worked as expected, it returned the HTML of the div. I'll keep you guys posted. Cheers, JB
eggwise's picture

HTTP endpoint - IE7

Guys, I went back to the Tryit page to find out whatis going on with the sendmail function in IE7. These are my conclusions:   In Safari/FF2/FF3/IE6 all works as expected. I can send emails up to 4000 characters from SOAP/HTTPS/HTTP endpoints In IE7 all works as expected for SOAP/HTTPS. When sending (html formatted) emails from HTTP endpoint (which we use in our gadgets) no emails can be send bigger than approx 800 charcters. That was the reason our mailfunction failed in IE7, the messages were bigger that 800 char (which is easy when HTML formatted) Now we have a problem: The mail function in our gadgets is rather a core function and we should be able to send emails from IE7 clients >800 charcters. It took me several hours to find out, and I don't know how to fix this. Maybe there is an error in the stub generation for the HTTP endpoint i.c.m. sending bigger request (including the email body) to the server.   Please help.   JB
jonathan.wso2.com's picture

Script injection engaged?

There is a known limitation on payload size when using script injection (which gets engaged automatically when a cross-site-scripting error is encountered.) But if this works in the tryit that doesn't sound like what's going on. Can you verify that the domain of the mashup and the domain of the tryit are the same? You're not copying the tryit to another server are you? I will try to repro the issue, if you could supply a minimal reproducible procedure and test case that would speed things up a lot.
eggwise's picture

Hi Jonathan

I confirm the Tryit and the Mashup are on the same domain. this is the Mashup code, all other things are removed. this.serviceName = "ms_990ml"; this.documentation = "Wraps the email object"; sendMail.documentation = "Send E-mail" ; sendMail.inputTypes = { "from":"string", "to":"string", "subj":"string", "msg":"string"} sendMail.outputType = "String"; function sendMail(from, to, subj, msg) { var email = new Email(); email.from = from; email.to = to; email.subject = subj; //email.text = msg; email.html = msg; email.send(); return "done"; } I incremented the number of characters in the msg textbox and it stuck at 750 or so with HTML endpoint for IE7. Thank you for helping. JB
jonathan.wso2.com's picture

Unable to reproduce

I'm having trouble reproducing this issue. Running the above code, configuring it to use a GMail account, and using "return msg.length;" to display the length of the message, it successfully sent messages of over 4000 characters in FF3 adn IE7 through the tryit to my wso2.com address. My test payload was simply <div><p>This is a <b>mail message</b></p>... repeated up the the several thousand character limit. Is there anything else that you noticed about your scenario that might be affecting this? Have you tried sending from different addresses? Can you try the "return msg.length;" to see if the message is actually getting to the service?
eggwise's picture

gmail

Hi Jonathan, Yeah I captured the length too. 100% positive it doesn't work in IE7 in our environment with more than 750 char. With redoing the tests today we could go up to 1919 char, not sure why it is more than yesterday, maybe our count was not ccurate yesterday??) We don't use gmail as SMTP server but our own. I'll send you a screen dump of the error message I get from WSO2, Maybe we can do it other way round. If I may have your code without your gmail credentials I try to run it in our Mashup server. Thx, JB the code   With SOAP endpoint no problems IN HTTP endpoint we could go up to 1919 char today With 1920 char we got this error
jonathan.wso2.com's picture

Thanks, that helped

I followed your screenshots exactly and am able to repro the issue now, thanks. I'll hopefully have something to report later today.
jonathan.wso2.com's picture

Filed JIRA

Did some research to unearth the roots of this issue. Filed JIRA https://wso2.org/jira/browse/MASHUP-1137 to record the issue. The summary is, that the Mashup Server Javascript annotations have no way to set the httpLocationIgnoreUncited property, which allows parameters (other than those cited in the httpLocation template) to be serialized in the body. Without the ability to set this property from the Javascript there isn't an automatic way to serialize parameters into the body. With large parameters, or many small parameters, this ends up resulting in large URLs. However IE is limited to URLs of 2083 characters, hence the failure. Once the parameter is set in the WSDL, all else should work fine - the stub and tryit both process this annotation when it appears. Some workarounds are: 1) copy the WSDL 2.0 and add the whttp:locationIgnoreUncited attribute, and generate stubs and try-it off of this corrected WSDL. 2) copy the stub and manually set the "httpLocationIgnoreUncited" property of the HTTPBinding to true and use this patched stub. 3) in the HTML programatically add the httpLocationIgnoreUncited property with a line like: ._endpointDetails.HTTPEndpoint.httpignoreUncited = true; I would expect this feature to be added in the next release. WSO2 production or development support customers could request an earlier, even a hot, fix - see http://wso2.com/services/support/.
eggwise's picture

httpLocationIgnoreUncited

Hi Jonathan, I can't figure out how/where to set the httpLocationIgnoreUncited property. I added the our stub to this post. Can you please indicate where it should be added? Thanks, JB // Example stubs for ms_003e_cache operations. This function is not intended // to be called, but rather as a source for copy-and-paste development. // Note that this stub has been generated for use in DOM environments. function stubs() { // getresult operation try { /* anyType */ var getresultReturn = ms_003e_cache.getresult(/* string */ param_company, /* string */ param_usrname, /* string */ param_password, /* string */ param_actcode, /* string */ param_refresh); } catch (e) { // fault handling } // sendmail operation try { /* string */ var sendmailReturn = ms_003e_cache.sendmail(/* string */ param_from, /* string */ param_to, /* string */ param_subj, /* string */ param_msg); } catch (e) { // fault handling } } stubs.visible = false; var ms_003e_cache = new WebService("SOAP12Endpoint"); ms_003e_cache.getresult = function getresult(/* string */ _company, /* string */ _usrname, /* string */ _password, /* string */ _actcode, /* string */ _refresh) { var isAsync, request, response, resultValue; this._options = new Array(); isAsync = (this.getresult.callback != null && typeof(this.getresult.callback) == 'function'); request = this.getresult_payload(/* string */ _company, /* string */ _usrname, /* string */ _password, /* string */ _actcode, /* string */ _refresh); if (isAsync) { try { this._call( "getresult", request, function(thisRequest, callbacks) { if (thisRequest.error != null) { callbacks[1](thisRequest.error); } else { response = thisRequest.responseXML; if (response == null) { resultValue = null; } else { resultValue = /* xs:anyType */ WebService.utils._convertJSType(response.documentElement); } callbacks[0](resultValue); } }, new Array(this.getresult.callback, this.getresult.onError) ); } catch (e) { var error; if (WebServiceError.prototype.isPrototypeOf(e)) { error = e; } else if (e.name != null) { // Mozilla error = new WebServiceError(e.name, e.message + " (" + e.fileName + "#" + e.lineNumber + ")"); } else if (e.description != null) { // IE error = new WebServiceError(e.description, e.number, e.number); } else { error = new WebServiceError(e, "Internal Error"); } this.getresult.onError(error); } } else { try { response = this._call("getresult", request); resultValue = /* xs:anyType */ WebService.utils._convertJSType(response.documentElement); return resultValue; } catch (e) { if (typeof(e) == "string") throw(e); if (e.message) throw(e.message); throw (e.reason); } } return null; // Suppress warnings when there is no return. } ms_003e_cache.getresult_payload = function (/* string */ _company, /* string */ _usrname, /* string */ _password, /* string */ _actcode, /* string */ _refresh) { return '' + (_company == null ? '' : '' + this._encodeXML(_company) + '') + (_usrname == null ? '' : '' + this._encodeXML(_usrname) + '') + (_password == null ? '' : '' + this._encodeXML(_password) + '') + (_actcode == null ? '' : '' + this._encodeXML(_actcode) + '') + (_refresh == null ? '' : '' + this._encodeXML(_refresh) + '') + '' ; } ms_003e_cache.getresult_payload.visible = false; ms_003e_cache.getresult.callback = null; ms_003e_cache.sendmail = function sendmail(/* string */ _from, /* string */ _to, /* string */ _subj, /* string */ _msg) { var isAsync, request, response, resultValue; this._options = new Array(); isAsync = (this.sendmail.callback != null && typeof(this.sendmail.callback) == 'function'); request = this.sendmail_payload(/* string */ _from, /* string */ _to, /* string */ _subj, /* string */ _msg); if (isAsync) { try { this._call( "sendmail", request, function(thisRequest, callbacks) { if (thisRequest.error != null) { callbacks[1](thisRequest.error); } else { response = thisRequest.responseXML; if (response == null) { resultValue = null; } else { var extractedValue = WSRequest.util._stringValue(response.documentElement); resultValue = /* string */ extractedValue; } callbacks[0](resultValue); } }, new Array(this.sendmail.callback, this.sendmail.onError) ); } catch (e) { var error; if (WebServiceError.prototype.isPrototypeOf(e)) { error = e; } else if (e.name != null) { // Mozilla error = new WebServiceError(e.name, e.message + " (" + e.fileName + "#" + e.lineNumber + ")"); } else if (e.description != null) { // IE error = new WebServiceError(e.description, e.number, e.number); } else { error = new WebServiceError(e, "Internal Error"); } this.sendmail.onError(error); } } else { try { response = this._call("sendmail", request); var extractedValue = WSRequest.util._stringValue(response.documentElement); resultValue = /* string */ extractedValue; return resultValue; } catch (e) { if (typeof(e) == "string") throw(e); if (e.message) throw(e.message); throw (e.reason); } } return null; // Suppress warnings when there is no return. } ms_003e_cache.sendmail_payload = function (/* string */ _from, /* string */ _to, /* string */ _subj, /* string */ _msg) { return '' + (_from == null ? '' : '' + this._encodeXML(_from) + '') + (_to == null ? '' : '' + this._encodeXML(_to) + '') + (_subj == null ? '' : '' + this._encodeXML(_subj) + '') + (_msg == null ? '' : '' + this._encodeXML(_msg) + '') + '' ; } ms_003e_cache.sendmail_payload.visible = false; ms_003e_cache.sendmail.callback = null; // WebService object. function WebService(endpointName) { this.readyState = 0; this.onreadystatechange = null; this.scriptInjectionCallback = null; //public accessors for manually intervening in setting the address (e.g. supporting tcpmon) this.getAddress = function (endpointName) { return this._endpointDetails[endpointName].address; } this.setAddress = function (endpointName, address) { this._endpointDetails[endpointName].address = address; } // private helper functions this._getWSRequest = function() { var wsrequest; try { wsrequest = new WSRequest(); // try to set the proxyAddress based on the context of the stub - browser or Mashup Server try { wsrequest.proxyEngagedCallback = this.scriptInjectionCallback; wsrequest.proxyAddress = document.URL.substring(0,document.URL.indexOf("/services/")); } catch (e) { try { wsrequest.proxyEngagedCallback = this.scriptInjectionCallback; wsrequest.proxyAddress = system.wwwURL.substring(0,system.wwwURL.indexOf("/services/")); } catch (e) { } } } catch(e) { try { wsrequest = new ActiveXObject("WSRequest"); } catch(e) { try { wsrequest = new SOAPHttpRequest(); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { throw new WebServiceError("WSRequest object not defined.", "WebService._getWSRequest() cannot instantiate WSRequest object."); } } } return wsrequest; } this._endpointDetails = { "SOAP12Endpoint": { "type" : "SOAP12", "address" : "http://192.168.46.13:7762/services/admin/ms_003e_cache.SOAP12Endpoint/", "action" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "soapaction" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "httplocation" : { "getresult" : "getresult", "sendmail" : "sendmail" } }, "SecureSOAP12Endpoint": { "type" : "SOAP12", "address" : "https://192.168.46.13:7443/services/admin/ms_003e_cache.SecureSOAP12Endpoint/", "action" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "soapaction" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "httplocation" : { "getresult" : "getresult", "sendmail" : "sendmail" } }, "SOAP11Endpoint": { "type" : "SOAP11", "address" : "http://192.168.46.13:7762/services/admin/ms_003e_cache.SOAP11Endpoint/", "action" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "soapaction" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "httplocation" : { "getresult" : "getresult", "sendmail" : "sendmail" } }, "SecureSOAP11Endpoint": { "type" : "SOAP11", "address" : "https://192.168.46.13:7443/services/admin/ms_003e_cache.SecureSOAP11Endpoint/", "action" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "soapaction" : { "getresult" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/getresultRequest", "sendmail" : "http://services.mashup.wso2.org/ms_003e_cache/ServiceInterface/sendmailRequest" }, "httplocation" : { "getresult" : "getresult", "sendmail" : "sendmail" } }, "HTTPEndpoint": { "type" : "HTTP", "address" : "http://192.168.46.13:7762/services/admin/ms_003e_cache.HTTPEndpoint/", "httplocation" : { "getresult" : "getresult", "sendmail" : "sendmail" }, "httpmethod" : { "getresult" : "GET", "sendmail" : "POST" }, "fitsInURLParams" : { "getresult" : true, "sendmail" : true } }, "SecureHTTPEndpoint": { "type" : "HTTP", "address" : "https://192.168.46.13:7443/services/admin/ms_003e_cache.SecureHTTPEndpoint/", "httplocation" : { "getresult" : "getresult", "sendmail" : "sendmail" }, "httpmethod" : { "getresult" : "GET", "sendmail" : "POST" }, "fitsInURLParams" : { "getresult" : true, "sendmail" : true } } }; this.endpoint = endpointName; this.username = null; this.password = null; this._encodeXML = function (value) { var str = value.toString(); str = str.replace(/&/g, "&"); str = str.replace(/= 48 && buffer.charCodeAt(p) <= 57) p++; } else { millisecond = 0; } } else { hour = 0; minute = 0; second = 0; millisecond = 0; } var tzhour = 0; var tzminute = 0; // parse time zone if (buffer.charAt(p) != 'Z' && buffer.charAt(p) != '') { var sign = (buffer.charAt(p) == '-' ? -1 : +1); p++; tzhour = sign * buffer.substr(p,2); p += 3; tzminute = sign * buffer.substr(p,2); } var thisDate = new Date(); thisDate.setUTCFullYear(year); thisDate.setUTCMonth(month-1); thisDate.setUTCDate(day); thisDate.setUTCHours(hour); thisDate.setUTCMinutes(minute); thisDate.setUTCSeconds(second); thisDate.setUTCMilliseconds(millisecond); thisDate.setUTCHours(thisDate.getUTCHours() - tzhour); thisDate.setUTCMinutes(thisDate.getUTCMinutes() - tzminute); return thisDate; }, _nextPrefixNumber : 0, _QNameNamespaceDecl : function (qn) { if (qn.uri == null) return ""; var prefix = qn.localName.substring(0, qn.localName.indexOf(":")); if (prefix == "") { prefix = "n" + ++this._nextPrefixNumber; } return ' xmlns:' + prefix + '="' + qn.uri + '"'; }, _QNameValue : function(qn) { if (qn.uri == null) return qn.localName; var prefix, localName; if (qn.localName.indexOf(":") >= 0) { prefix = qn.localName.substring(0, qn.localName.indexOf(":")); localName = qn.localName.substring(qn.localName.indexOf(":")+1); } else { prefix = "n" + this._nextPrefixNumber; localName = qn.localName; } return prefix + ":" + localName; }, scheme : function (url) { var s = url.substring(0, url.indexOf(':')); return s; }, domain : function (url) { var d = url.substring(url.indexOf('://') + 3, url.indexOf('/',url.indexOf('://')+3)); return d; }, domainNoPort : function (url) { var d = this.domain(url); if (d.indexOf(":") >= 0) d = d.substring(0, d.indexOf(':')); return d; }, _serializeAnytype : function (name, value, namespace, optional) { // dynamically serialize an anyType value in xml, including setting xsi:type. if (optional && value == null) return ""; var type = "xs:string"; if (value == null) { value = ""; } else if (typeof(value) == "number") { type = "xs:double"; } else if (typeof(value) == "object" && value.nodeType != undefined) { type = "xs:anyType"; value = WebService.utils._serializeXML(value); } else if (typeof(value) == "boolean") { type = "xs:boolean"; } else if (typeof(value) == "object" && Date.prototype.isPrototypeOf(value)) { type = "xs:dateTime"; value = WebService.utils.toXSdateTime(value); } else if (value.match(/^\s*true\s*$/g) != null) { type = "xs:boolean"; } else if (value.match(/^\s*false\s*$/g) != null) { type = "xs:boolean"; } else if (!isNaN(Date.parse(value))) { type = "xs:dateTime"; value = WebService.utils.toXSdateTime(new Date(Date.parse(value))); } else if (value.match(/^\s*\-?\d*\-\d\d\-\d\dZ?\s*$/g) != null) { type = "xs:date"; } else if (value.match(/^\s*\-?\d*\-\d\d\-\d\d[\+\-]\d\d:\d\d\s*$/g) != null) { type = "xs:date"; } else if (value.match(/^\s*\d\d:\d\d:\d\d\.?\d*Z?\s*$/g) != null) { type = "xs:time"; } else if (value.match(/^\s*\d\d:\d\d:\d\d\.?\d*[\+\-]\d\d:\d\d\s*$/g) != null) { type = "xs:time"; } else if (value.match(/^\s*\-?\d*\-\d\d\-\d\dT\d\d:\d\d:\d\d\.?\d*Z?\s*$/g) != null) { type = "xs:dateTime"; } else if (value.match(/^\s*\-?\d*\-\d\d\-\d\dT\d\d:\d\d:\d\d\.?\d*[\+\-]\d\d:\d\d\s*$/g) != null) { type = "xs:dateTime"; } else if (value.match(/^\s*\d\d*\.?\d*\s*$/g) != null) { type = "xs:double"; } else if (value.match(/^\s*\d*\.?\d\d*\s*$/g) != null) { type = "xs:double"; } else if (value.match(/^\s*\"; var endtag = ""; return starttag + value + endtag; }, _serializeXML : function(payload) { var browser = WSRequest.util._getBrowser(); switch (browser) { case "gecko": case "safari": var serializer = new XMLSerializer(); return serializer.serializeToString(payload); break; case "ie": case "ie7": return payload.xml; break; case "opera": var xmlSerializer = document.implementation.createLSSerializer(); return xmlSerializer.writeToString(payload); break; case "undefined": throw new WebServiceError("Unknown browser", "WSRequest.util._serializeToString doesn't recognize the browser, to invoke browser-specific serialization code."); } }, // library function for dynamically converting an element with js:type annotation to a Javascript type. _convertJSType : function (element, isWrapped) { if (element == null) return ""; var extractedValue = WSRequest.util._stringValue(element); var resultValue, i; var type = element.getAttribute("js:type"); if (type == null) { type = "#raw"; } else { type = type.toString(); } switch (type) { case "string": return extractedValue; break; case "number": return parseFloat(extractedValue); break; case "boolean": return extractedValue == "true" || extractedValue == "1"; break; case "date": return WebService.utils.parseXSdateTime(extractedValue); break; case "array": resultValue = new Array(); for (i=0; i
jonathan.wso2.com's picture

Workaround

Sorry for not being adequately specific in my workaround! I put a little more detail in the JIRA, but got it wrong there too. In the code importing the stub above (no need to edit the stub itself), add this line: ms_003e_cache._endpointDetails.HTTPEndpoint.httpignoreUncited = {"sendmail" : true, "getresult" : false}; This will prevent any of the parameters from appearing in the URL for the sendmail operation, but not affect the getresult operation - you can adjust to suit each operation. Note that _endpointDetails is not a documented public structure, and this workaround may fail if its structure changes in a future version, which is why we still need a JIRA to provide a real fix.
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)