frappe.preview_email = function(template, args, header) {
	frappe
		.call({
			method: 'frappe.email.email_body.get_email_html',
			args: {
				subject: 'Test',
				template,
				args,
				header
			}
		})
		.then(r => {
			var html = r.message;
			html = html.replace(/embed=/, 'src=');
			var d = frappe.msgprint({
				message:
					'<iframe width="100%" height="600px" style="border: none;"></iframe>',
				wide: true
			});

			setTimeout(() => {
				d.$wrapper
					.find('iframe')
					.contents()
					.find('html')
					.html(html);
				d.$wrapper.find('.modal-dialog').css('width', '70%');
			}, 1000);
		});
};

@@ -51,13 +51,37 @@
 ader
-) %7B%0A%09
+, only_html=false) %7B%0A%09return 
 frap
@@ -305,16 +305,58 @@
 src=');%0A
+%09%09%09if (only_html) %7B%0A%09%09%09%09return html;%0A%09%09%09%7D%0A
 %09%09%09var d

Update preview_email function to return only HTML