1

I have a page (specifically, a Chrome developer extension) used for debugging client installations of some software. If clients need more help for a specific problem that they are observing, we want them to be able to email us with documentation of the problem.

Is there a way for a mailto to add (as an attachment or a frame within the email body) a file of the current html page the mailto is on? The page is dynamically generated locally, so it would be preferable if the page didn't have to be uploaded anywhere but the email.

Clay Thomas
  • 198
  • 7

4 Answers4

2

Look at this w3schools example: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_links_mailto_subject

(formatted excerpt, you will want the href="" to be all on one line) <a href=" mailto:someone@example.com?cc=someoneelse@example.com &bcc=andsomeoneelse@example.com&subject=Summer%20Party &body=You%20are%20invited%20to%20a%20big%20summer%20party!" target="_top"> Send mail! </a>

You can use javaScript to insert into the link the page as you need.

EDIT:

Just noticed that you might want to be careful with 'larger' pages, as there is a limit to how long a GET request (which this is) can be: maximum length of HTTP GET request?

tl:dr: You might want to narrow the scope of what code is included if you use this method

Community
  • 1
  • 1
Snappawapa
  • 1,697
  • 3
  • 20
  • 42
  • you might have answered before he clarified but this no longer answers the question – Zig Mandel Jun 23 '15 at 14:21
  • @Zig Mandel I think that this would be a relevant answer.. Why does this no longer answer the question? – Snappawapa Jun 23 '15 at 14:38
  • see the comments below his q by op "he HTML itself...." hes not asking to send a link to the html page – Zig Mandel Jun 23 '15 at 17:23
  • you could easily do some JavaScript DOM functions to get what you need into the link.. `document.innerHTML` for example – Snappawapa Jun 23 '15 at 17:26
  • because its not a snapshot of their actual view which could have data specific to them. in any case thats what he's asking,'to include the html and images – Zig Mandel Jun 23 '15 at 22:50
1

Short answer: No.

The mailto in an a tag is only used to specify a link to an email, not the contents of said email. You would need to use some sort of server-side AJAX call. I would recommending using PHP's mail() function if you can.

Example

You would need to set the email header to be HTML compliant.

So, if you're using the PHP mail() function:

$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "CC: susan@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

mail("target@something.com", "subject", "PLACE HTML HERE", $headers);

Then you could theoretically just pass off in the AJAX request all of the data from the page:

$.ajax({
    url: "http://my.url.com/endpoint/",
    method: "POST",
    data: {
        page: $("html").html()
    }
});

Which you would then just embed somewhere in the email, or straight into the body. You could even add extra data for the GET and POST parameters present.

Note

While I can see this being used for some debugging, a lot of errors are caused via Javascript failing in some way or your PHP/server-side code failing. I'd recommend that whatever path you choose, including one I haven't covered, you should also include data from the console, POST, and GET variables if you have access to those (although be careful not to expose the POST and GET variables unnecessarily).

There are also a lot of tools like Chrome Remote Desktop that can help you view specific errors and problems that users are experiencing.

Alternately, to get around the mail() function, you could have embedded debugging Javascript which can dynamically send debugging information from their browser (via an AJAX request) to a server, that intercepts it for you to analyze and debug.

Aeolingamenfel
  • 2,399
  • 1
  • 15
  • 22
1

its not possible to include attachments using mailto:

one way to do this is to use mailto: to create a text message with two links:

  1. the page url

  2. the url of a png capture of the page.

there are chrome apis to capture the screen, and you can use your server or something like imgur to save the capture. probably better to use your own server that receives the images as imgur could be a privacy concern for your users.

Zig Mandel
  • 19,571
  • 5
  • 26
  • 36
0

It seems like a full answer is impossible, but I thought I'd share the route I took.

I have a button with id='save-log'. In the page where I add all the necessary events, I have

document.getElementById('save-log').addEventListener('click',
  function(e){
    chrome.runtime.sendMessage({
      log: document.body.innerHTML
    });
  }
);

Then in a background page I have

chrome.runtime.onMessage.addListener(
  function(message, sender, sendResponse) {
    chrome.tabs.create({
      url: "save-log.html?" + message.log
    });
  }
);

And finally, in save-log.html I have the necessary styling information, with an empty body, and run the script:

document.write(decodeURIComponent(location.search.substring(1)));

Now there's a new tab with a full copy of the developer extension panel, and the user can save the html page and send it to whoever they want.

Clay Thomas
  • 198
  • 7