locked
Load grid view inside outlook message using Jquery Styling not working. RRS feed

  • Question

  • User-1309553206 posted
     Emailbody = document.getElementById('<%=GVExternalUsers.ClientID%>').outerHTML;
    
                     var decodedString
                 var parser = new DOMParser;
                 var dom = parser.parseFromString(
                     '<!doctype html><body>' + Emailbody,
                     'text/html');
                 decodedString = dom.body.textContent;
                window.location.href = "mailto:?body=" + decodedString + "&subject=" + Emailsubject;

    I am trying to load grid view with inside outlook using jquery. When I use the above code it is working but it is loading just text,
    I need to keep the gridview styling as well. how can I do that??

    Tuesday, June 5, 2018 7:25 PM

All replies

  • User-1309553206 posted
    I still need help in loading the grid with correct styling because all I see is text inside the mail.
    Tuesday, June 5, 2018 7:39 PM
  • User-474980206 posted
    Because you use textContent, you are stripping all markup and only have plain text.
    Wednesday, June 6, 2018 12:12 AM
  • User283571144 posted

    Hi smilingLily,

    According to the RFC 2368 aticle's section2, you could find the body field is supposed to be in text/plain format, so you couldn't send the email body as html body.

    If you want to send the html body as E-mail body, I suggest you could try to send the e-mail in code-behind.

    For exmaple: you could use some library(e.g Spire.Email) to send the E-mail.

    More details about how to send the E-mail in code-behind with html body, you could refer to below codes:

    https://www.e-iceblue.com/Knowledgebase/Spire.Email/Spire.Email-Program-Guide/Send-Email-with-HTML-Body-in-C-VB.NET.html 

    Best Regards,

    Brando

    Wednesday, June 6, 2018 8:28 AM
  • User-1309553206 posted

    I implemented it in the code behind 1st. But we are not sending the email just opening the grid in outlook and then its upto end user to send the email or not.

    The server I have the web application hosted does not have outlook installed. so I needed to implement this functionality on the client side.

    Wednesday, June 6, 2018 2:29 PM
  • User-474980206 posted

    all the mailto url body parameters in the way of markup is spaces (%20) and line breaks (%0A). you might get a table look using tabs and spaces, but you can not insert html tags.

    if this s an internal app, you could use EWS or the office graph api to create a draft document with markup.

    Wednesday, June 6, 2018 4:06 PM