JavaScript - Outlook Line Breaks
Hi,
I'm creating a new email in javascript via outlook. When i try entering a line break "\n", "\r", "\r\r", etc, Outlook just ignores it completely. I've tried using "%0D%0A" and "fromCharCode(10)" as well but it doesnt seem to read it as a line break. Is there any way to code it so that a line break or a carriage return appears on outlook? Similar TutorialsHi, I am facing one problem when i am trying to open the outlook express through javascript. Here i am able to open the outlook express with all the data, but when i press enter on any line of the body if the message, it moves 2 lines. Can any body help me to make it to single spacing. The code i have used is given below. sendemail.js Quote: // JScript File function EmailIt(task,issue_id,emailTO,strTitle,strsubsystem,chkAvailableAll,ddlJob,ddlSystem,ddlTester,ddlPr iority,txtDueDate,ddlAssignedTo,ddlStatus) { //win = window.open("...\\Issues\\HTMLPage3.htm"); var daReferrer = document.referrer; //var task = escape(document.URLUnencoded); //var issue_id = document.URLUnencoded.split("="); var email = emailTO; var title = strTitle; var subsystem = strsubsystem; var availableall = chkAvailableAll; var CustomerJob = ddlJob; var System = ddlSystem; var DueDate = txtDueDate; var AssignedTo = ddlAssignedTo; var Priority = ddlPriority; var Tester = ddlTester; var Status = ddlStatus; var subject = "Issue Task number is " + issue_id + " - " + escape(title) ; var body_message = " Your Assigned Task is.%0D " + escape(task); //+ escape("\n") + " :subsystem ===>"+ subsystem + escape("\n") + " :title ===>" + title + escape("\n") + "available all ===>" +availableall; body_message += escape("\n"); body_message += escape("\n"); body_message += " Customer/Job : " + escape(CustomerJob); body_message += escape("\n"); body_message += " Available For All : " + escape(availableall); body_message += escape("\n"); body_message += " System : " + escape(System); body_message += escape("\n"); body_message += " Sub System : " + escape(subsystem); body_message += escape("\n"); body_message += " Title : " + escape(title); body_message += escape("\n"); body_message += " DueDate : " + escape(DueDate); body_message += escape("\n"); body_message += " AssignedTo : " + escape(AssignedTo); body_message += escape("\n"); body_message += " Priority : " + escape(Priority); body_message += escape("\n"); body_message += " Tester : " + escape(Tester); body_message += escape("\n"); body_message += " Status : " + escape(Status); body_message += escape("\n"); //alert("body_message:--> " + body_message); var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message; //alert("mailto_link: " + mailto_link); win = window.open(mailto_link); if (win && win.open &&!win.closed) win.close(); //window.history.back(-1); } Can any body please help me to come out this problem. Regards, Vimal kumar srivastava Madhepura,India I pulled together a custom RSS twitter feed that uses javascript; however, when I tell the code to "callback" 3 posts, they all run together without line breaks. What is the best way to have breaks between the posts? This page shows the html code (in the right sidebar): http://www.westbrockdesign.com/twitter.html The javascript looks like this: Code: function twitterCallback2(C){var A=[];for(var D=0;D<C.length;D++){var E=C[D].user.screen_name;var B=C[D].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g,function(F){return'<a href="'+F+'">'+F+"</a>"}).replace(/\B@([_a-z0-9]+)/ig,function(F){return F.charAt(0)+'<a href="http://www.twitter.com/'+F.substring(1)+'">'+F.substring(1)+"</a>"});A.push("<span>"+B+'</span> <a style="font-size:85%" href="http://twitter.com/'+E+"/statuses/"+C[D].id+'">'+relative_time(C[D].created_at)+"</a>")}document.getElementById("twitter_gretchen").innerHTML=A.join("")}function relative_time(C){var B=C.split(" ");C=B[1]+" "+B[2]+", "+B[5]+" "+B[3];var A=Date.parse(C);var D=(arguments.length>1)?arguments[1]:new Date();var E=parseInt((D.getTime()-A)/1000);E=E+(D.getTimezoneOffset()*60);if(E<60){return"less than a minute ago"}else{if(E<120){return"about a minute ago"}else{if(E<(60*60)){return(parseInt(E/60)).toString()+" minutes ago"}else{if(E<(120*60)){return"about an hour ago"}else{if(E<(24*60*60)){return"about "+(parseInt(E/3600)).toString()+" hours ago"}else{if(E<(48*60*60)){return"1 day ago"}else{return(parseInt(E/86400)).toString()+" days ago"}}}}}}}; Any insights would be much appreciated! I must have spent around 8 hours looking for the JavaScript code I need for putting text on the screen using onclick. Here is the code I found: http://javascript.internet.com/snipp...functions.html Code: /* This script and many more are available free online at The JavaScript Source!! http://javascript.internet.com Created by: HunBug | http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11430 */ function appendText(node,txt) { node.appendChild(document.createTextNode(txt)); } function appendElement(node,tag,id,htm) { var ne = document.createElement(tag); if(id) ne.id = id; if(htm) ne.innerHTML = htm; node.appendChild(ne); } That works great, but I need to add three lines of text at a time, not just one. I spent at least 4 more hours searching for ways to add a line break with JavaScript, but nothing I have found works with this code. Here's what the onclick code looks like: Code: onclick="appendText(document.getElementById('bb1'),'8,4,6' + '0,0,0' + '16'); <div id="bb1"></div> The page I'm working on will have clickable text and image maps and when you click, three lines of batari Basic code will be added to a DIV. Here's an example of what that code will look like: Code: 8,4,6 0,0,0 16 Click on another link and you'd see something like this: Code: 8,4,6 0,0,0 16 8,12,17 0,0,0 16 It would keep adding three lines of batari Basic code to the list every time you clicked. If somebody can figure out how to stick line breaks in this code that really work, I'll be all set. I have tried <BR>, \n, \r\n and a couple of other things, but nothing works so far. Thanks. Hi I currently have this: var d = new Date() var theDay = d.getDay() switch (theDay) { case 1: document.write("On Air Tonight...") <br> document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") break case 2: document.write("On Air Tonight...") document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") break case 3: document.write("On Air Tonight...") document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") break case 4: document.write("On Air Tonight...") document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") break case 5: document.write("On Air Tonight...") document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") break case 6: document.write("On Air Tonight...") document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") break case 7: document.write("On Air Tonight...") document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") break default: document.write("On Air Tonight...") document.write("ALAN POWELL!") document.write("8pm - 10pm") document.write("CARL KANE!") } Which obviously outputs the following: On Air Tonight...ALAN POWELL!8pm - 10pmCARL KANE! How do i code it so it displays On Air Tonight... ALAN POWELL! 8pm - 10pm CARL KANE! Also in Firefox, its not displaying ANYTHING... is there anything wrong in the code which FF would throw out? CSS validation says everything is ok any help would be fantastic. Thanks in advance UKD. I have a piece of javascript that attaches a PDF document to an outlook form. However the PDF that I am pulling has a default name such as 'test' and I would like to change it to say 'client.pdf'. Is this possible in the script below? var theApp = new ActiveXObject("Outlook.Application"); var theMailItem = theApp.CreateItem(0); theMailItem.to = "test@test.com" theMailItem.Subject = "test"; theMailItem.Attachments.add("http://someURL/test?abc.pdf"); It currently saves the attachment as 'test' instead of abc.pdf (i.e. it seems to pick up the text before the question mark). Anyway of changing/settign the name differently? Many thanks Hey All, Been having some trouble with this, I am trying to find a javascript or DHTML form field which is similar to the outlook web access email address fields which show an icon to identify the address, and the screen name of the address instead of the full email address, as a hyperlink. I was wanting to know if anyone knows of something like this already around or if I need to design my own. Thanks in advance. Hi, I am new to Microsoft Outlook. I want to send a email using Microsoft Outlook. But that needs to send HTML email , I have tried for this but not getting the solution. I tried a lot by using <html> but it doesn't work. The code i have used is given below. Could you guys please help me out in this. Please make me know how can I send my email in html using Outlook Express ? .aspx.cs Quote: private void SendMail(DropDownList ddllist, TextBox txtTitle, TextBox txtSubSystem) { string email = string.Empty; string lastName = string.Empty; string title = string.Empty; string subsystem = string.Empty; string task = string.Empty; string issue_id = string.Empty; try { //DropDownList ddlAssignedTo = (DropDownList)fvIssue.FindControl("ddlAssignedTo"); string tb_assigned_to = ddllist.SelectedValue; task = Request.Url.OriginalString.ToString(); issue_id = Request.Url.OriginalString.ToString().Split('=')[2]; title = txtTitle.Text.Replace("'", " "); subsystem = txtSubSystem.Text.Replace("'", " "); if (tb_assigned_to != null) { if (tb_assigned_to.Equals(ConstValues.SCANNER_GROUP) || tb_assigned_to.Equals(ConstValues.SERVER_GROUP) || tb_assigned_to.Equals(ConstValues.TEST_GROUP)) { Session["emailTo"] = Util.GetGroupEmails(tb_assigned_to); } else { CdsContactBLL contact = new CdsContactBLL(); email = contact.EmailAddress(tb_assigned_to); if (email != string.Empty) Session["emailTo"] = email; else Session["emailTo"] = tb_assigned_to + "_DOES_EXIST_IN_CDS_CONTACT@datascanlp.com"; } } else Session["emailTo"] = "TO_EMAIL_GOES_HERE@test.com"; } catch (Exception ex) { Session["emailTo"] = "TO_EMAIL_GOES_HERE@test.com"; } InjectScript.Text = "<script type=\"text/javascript\">EmailIt('" + task + "','" + issue_id + "','" + Session["emailTo"].ToString() + "','" + title + "','" + subsystem + "')</script>"; } SendEmail.js Quote: // JScript File function EmailIt(task,issue_id,emailTO,strTitle,strsubsystem) { //win = window.open("...\\Issues\\HTMLPage3.htm"); var daReferrer = document.referrer; //var task = escape(document.URLUnencoded); //var issue_id = document.URLUnencoded.split("="); var email = emailTO; var title = strTitle; var subsystem = strsubsystem; var subject = "Issue Task number is " + issue_id + " - " + escape(title) ; var body_message = " Your Assigned Task is.%0D " + escape(task); body_message += escape("\n"); body_message += escape("\n"); body_message += " Sub System : " + escape(subsystem); body_message += escape("\n"); body_message += " Title : " + escape(title); body_message += escape("\n"); var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message; win = window.open(mailto_link); if (win && win.open &&!win.closed) win.close(); //window.history.back(-1); } Regards, vimal kumar srivastava Madhepura,India Hello I'd like to open using JS an outlook send mail window having a file from the server (full url, that should work, right ?) attached. Is this possible ? If so, please tell me how. Thanks My page is he http://acq.matthewboehler.com/ I have jQuery script written on my page to create a fade-effect when an image is hovered. See the large, kitchen image in the middle of the screen to see this effect in action. This is done on images with the "fade" class and styled with the second image as its background image. My problem is when I apply the "fade" class to another image, the background image does not appear on a rollover. See the bottom left corner image, when you rollover it goes away. Can someone explain why? I am trying to get a site working that some hack developed. Got it nearly operational, except for one page, the down arrows do not work. They fire via javascript. It is just a hover and scroll deal. The java gets loaded the same for every page, but it breaks on this one. I am decent with some coding, but I know I am light years behind the smart people in this forum, especially when it comes to java. I really could use a hand. Thanks Working scroll: http://66.147.244.241/~finalco1/inde...mation-fm.html The broken scroller: http://66.147.244.241/~finalco1/inde...act-us-fm.html I have the following code: Code: <script> $(function() { var inputArr = new Array("#register_id #username_id", "#register_id #email_id", "#register_id #password1_id", "#register_id #password2_id", "#signin_id #email_id", "#signin_id #password_id"); var inputToOverlayDict = new Array(); inputToOverlayDict[inputArr[0]] = "#register_id #usernameOverlay_id"; inputToOverlayDict[inputArr[1]] = "#register_id #emailOverlay_id"; inputToOverlayDict[inputArr[2]] = "#register_id #passwordOverlay1_id"; inputToOverlayDict[inputArr[3]] = "#register_id #passwordOverlay2_id"; inputToOverlayDict[inputArr[4]] = "#signin_id #emailOverlay_id"; inputToOverlayDict[inputArr[5]] = "#signin_id #passwordOverlay_id"; var i; for(i=0; i<6; i++) { $(inputArr[i]).focus(function() { $(inputToOverlayDict[inputArr[i]]).hide(); }); } /* $(inputArr[0]).focus(function() { $(inputToOverlayDict[inputArr[0]]).hide(); }); $(inputArr[0]).blur(function() { if($(this).val().length == 0) $(inputToOverlayDict[inputArr[0]]).show(); }); $(inputArr[1]).focus(function() { $(inputToOverlayDict[inputArr[1]]).hide(); }); $(inputArr[2]).focus(function() { $(inputToOverlayDict[inputArr[2]]).hide(); }); $(inputArr[3]).focus(function() { $(inputToOverlayDict[inputArr[3]]).hide(); }); $(inputArr[4]).focus(function() { $(inputToOverlayDict[inputArr[4]]).hide(); }); $(inputArr[5]).focus(function() { $(inputToOverlayDict[inputArr[5]]).hide(); }); */ }); </script> The whole idea is that if a certain div object comes to focus, something else disappears (using JQuery). For some reason the code in the comments is working fine, but the for loop breaks everything down. Why? I have the below JS code to change up a select box based on what is selected in another select box. IE9 broke this somehow. It still works in other browsers as well as IE8 and IE7. When you select something in select box A, it properly populates select box B. However when you go back and change select box A again the script stops working completely. The error I'm getting from the IE9 developer tools debugger is: SCRIPT65535: Invalid calling object dynamicselect.js, line 31 character 18 I have bolded the relevant line below. Code: function dynamicSelect(id1, id2) { // Browser and feature tests to see if there is enough W3C DOM support var agt = navigator.userAgent.toLowerCase(); var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); var is_mac = (agt.indexOf("mac") != -1); if (!(is_ie && is_mac) && document.getElementById && document.getElementsByTagName) { // Obtain references to both select boxes var sel1 = document.getElementById(id1); var sel2 = document.getElementById(id2); // Clone the dynamic select box var clone = sel2.cloneNode(true); // Obtain references to all cloned options var clonedOptions = clone.getElementsByTagName("option"); // Onload init: call a generic function to display the related options in the dynamic select box refreshDynamicSelectOptions(sel1, sel2, clonedOptions); // Onchange of the main select box: call a generic function to display the related options in the dynamic select box sel1.onchange = function() { refreshDynamicSelectOptions(sel1, sel2, clonedOptions); }; } } function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) { // Delete all options of the dynamic select box while (sel2.options.length) { sel2.remove(0); } // Create regular expression objects for "select" and the value of the selected option of the main select box as class names var pattern1 = /( |^)(select)( |$)/; var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)"); // Iterate through all cloned options for (var i = 0; i < clonedOptions.length; i++) { // If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) { // Clone the option from the hidden option pool and append it to the dynamic select box sel2.appendChild(clonedOptions[i].cloneNode(true)); } } } Thank you in advance for any help provided. here is my code Code: <ul id="myList" class="myList"> <form method="post" action="somepage"> <li id="item_1"> <a href="#"><img src="images/build/handle.jpg" alt="handle" border="0" /></a> Link Group </li> <li id="item_2"> <a href="#"><img src="images/build/handle.jpg" alt="handle" border="0" /></a> Page Group </li> <li id="item_3"> <a href="#"><img src="images/build/handle.jpg" alt="handle" border="0" /></a> SEO </li> <li id="item_4"> <a href="#"><img src="images/build/handle.jpg" alt="handle" border="0" /></a> <script type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced" }); function toggleEditor(id) { if (!tinyMCE.get(id)) tinyMCE.execCommand('mceAddControl', false, id); else tinyMCE.execCommand('mceRemoveControl', false, id); } </script> <textarea name="content" style="width:96%"> </textarea> <a href="javascript:toggleEditor('content');">Add/Remove editor</a> </li> </form> </ul> <p id="myList_serialize"></p> <script type="text/javascript" language="javascript" charset="utf-8"> Sortable.create('myList',{ghosting:false,constraint:true,hoverclass:'over', onChange:function(element){ var totElement = 7; var newOrder = Sortable.serialize(element.parentNode); for(i=1; i<=totElement; i++){ newOrder = newOrder.replace("myList[]=",""); newOrder = newOrder.replace("&",","); } $('myList_serialize').innerHTML = '<strong>New Order</strong>: '+newOrder; } }); </script> I some draggable li's which works fine, I have a tinyMCE WYSIWYG editor which works fine! How can I add a form to my UL LI? This is about http://www.aecp.pt You will see this on the page, and I highlight the problem on the screenshot itself: http://skitch.com/ricardosalta/nk9g4...ub-de-portugal I know by trial and error that the problem is caused by the presence of image galleries like this on the homepage: http://skitch.com/ricardosalta/nk988...ub-de-portugal I use Mac; is there a good tool to find these incompatibilities? Anyway, I appreciate all the help you can gift me with. Any pointers will be much valuable. Thanks. All the best, Tatonka Hi, I have my page here. There is a tab system on the page that uses javascript. View the source the see the javascript file (tabber9.compressed.js). Now, on my end, I am adding some tracking code. The code looks like this: Code: <SCRIPT TYPE='text/javascript' LANGUAGE='JavaScript'><!-- // window.onload = initPage; function initPage() { if (this.GetCustomerGUID) document.forms["Test"].elements["CustomerGUID"].value = GetCustomerGUID(); } //--></SCRIPT> The problem is, when I add this code to my footer, it breaks the tab system. The tabs don't work any more. I am not a JavaScript expert by any means (or else I would have known what the issue is! lol) but, I guess it has something to do with the window.onload function? I say that because I see the window.onload code in the tabber javascript as well. Any advice or help anyone can give would be greatly appreciated. Thanks in advance for any help! hi, I have some HTML to edit in my database, in my back end administration I have it in a textarea but when I go to edit it, it all messes up and lots of '/' area added, see below: Code: Site Design by: <a href=\\\\\\\"http://www.jbiddulph.com\\\\\\\" target=\\\\\\\"_blank\\\\\\\" title=\\\\\\\"John Biddulph - Web Development\\\\\\\">jbiddulph.com</a> php code Code: <p> <label>Site Design by</label> <textarea class="text-input small-input" name="SiteDesignby"><?php echo $row1['SiteDesignby'] ?></textarea> </p> Can anyone help please? i am dynamically making pdf files, works great using abcpdf etc etc. the only problem that i am having is with the page breaking. i want to create a function that runs onload and can read the position of elements and add breaks before the element if it is cut off. each block ("from the west", "holiday inn express") is a span with the class name of "entry" i want to loop through those, get their height, add them together and if that span falls in the range of the page size (792px) add a page break before it. the difficult part will be when we get to pages 2 and above does that make sense? im throwing around some ideas now in a js file, if you have any please post them thanks Hello; I am testing some code that finds and element and attempts to add an event handler attribute to it as 'onclick' (test case in Firefox 3.5.9) /* The actual code is: window.onload = function() { //<irrelevant code> var test = document.getElementById('tstEl'); test.setAttributeNode('onclick'); test.setAttribute('onclick', "alert(\"Don\'t get testy\")"); } */ The error per the js console in Firefox is: Error: uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMHTMLInputElement.setAttributeNode]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://192.168.1.6/<pathInfo>/SC_branch2_dev.php :: anonymous :: line 35" data: no] I am trying to do this because Element.addEventListener or Element.attachEvent won't allow for arguments to be passed to the event handler code/function. What is going on here? The only line referenced, line35, in the document text containing javascript code is irrelevant to the problem. Thank you for time, interest and attention; WhoEverIReallyAm |