-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding support to send HTML rendered code embeded in Email #221
Comments
Have a look at: How to Code HTML Email Newsletters for some of the issues around HTML emails. Having generated these myself from scratch in scripts, the rule seems to be 'simple is best'. Not sure if that helps very much. |
Ho great, that is exactly something I have been looking for actually. thanks @wightsci In the end, there a few things that
We ce can/must do for sure is the following:
DesignThinking out loud On the design part of things I am unsure what the best approach would be. As we don't want to have any dependencies on any of the
How could this look likeI want to have an open discussion on how this could look like. I see several possible scenarios which I would like to discuss.
for the moment, I cannot think of other solutions, but please share your ideas, thoughts on how this could:
Looking forward to your feedback ideas critics and design proposals. |
As I said in my comment – I’ve had to deal with this situation before, both for messages I’ve generated myself and trying to help people who were creating messages by hand. It’s not fun. I think that the success of using PSHTML for email depends to a great extent on the email client of the recipient, which is out of our hands.
Just to try to understand the scope of what you are trying to achieve, what is ‘report generator’ ?
Regards,
Stuart.
|
Good idea ! |
@christophekumor have a look at the link from @wightsci above. Everything is described in there already apperently |
Ok, i just wanted to share my own personal experience about generating email with powershell. Sorry |
hi,
important part: this is part of chartjs. It will call the RemoveCanvasAndCreateBase64Image js function when the chart animation is completed. We can not do this before! or the base64image will represent a white image.
second important part, the js function that do to work for you :) all of this JS code must be added into the Then we must change the this is the easy part. I recommand using https://github.com/adamdriscoll/selenium-powershell to be able to fetch the code of the generated page (the one after the javascript is executed ... ! ) Might be a better way to do this ! Edit: $drivers = Start-SeChrome
Enter-SeUrl -Driver $drivers -Url C:\temp\pshtml\BarChart1.html
sleep 10
$drivers.pagesource | out-fille c:\temp\pshtml\barchart_withoutJS.html Edit2: [String] GetDefinition([String]$CanvasID,[Bool]$ToBase64){
$FullDefintion = [System.Text.StringBuilder]::new()
$FullDefintion.Append($this.GetDefinitionStart([String]$CanvasID))
$FullDefintion.AppendLine($this.GetDefinitionBody())
$FullDefintion.AppendLine($this.GetDefinitionEnd())
$FullDefintion.AppendLine("function RemoveCanvasAndCreateBase64Image (){")
$FullDefintion.AppendLine("var base64 = this.toBase64Image();")
$FullDefintion.AppendLine("var element = this.canvas;")
$FullDefintion.AppendLine("var parent = element.parentNode;")
$FullDefintion.AppendLine("var img = document.createElement('img');")
$FullDefintion.AppendLine("img.src = base64;")
$FullDefintion.AppendLine("img.name = element.id;")
$FullDefintion.AppendLine("element.before(img);")
$FullDefintion.AppendLine("parent.removeChild(element);")
$FullDefintion.AppendLine("};")
$FullDefintion.replace('"RemoveCanvasAndCreateBase64Image"','RemoveCanvasAndCreateBase64Image')
$FullDefintionCleaned = Clear-WhiteSpace $FullDefintion
return $FullDefintionCleaned
} Somewhere we also need to add the |
function RemoveCanvasAndCreateBase64Image (){
var base64 = this.toBase64Image();
var element = this.canvas;
var parent = element.parentNode;
var img = document.createElement('img');
img.src = base64;
img.name = element.id;
element.before(img);
parent.removeChild(element);
//var scripttags = document.getElementsByTagName('script');
//var scripttags = document.getElementsByTagName('script');
//for (i=0;i<scripttags.length;){
// var parent = scripttags[i].parentNode;
// parent.removeChild(scripttags[i]);
//}
}; this is an updated version of the function to create the base64 img. |
Rendering HTML to be send directly in an Email can be a bit different, as some of the styles seem to work differently. This issue is to identify
The solution (might / could) be as simple as just create a specific CSS style that will apply 'only' to HTML code that is intended to be used in an Email.
The text was updated successfully, but these errors were encountered: