Skip to content

Commit d008975

Browse files
Fix #80
1 parent 4ac1abf commit d008975

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

PSWriteHTML.psd1

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Przemyslaw Klys
55
#
6-
# Generated on: 12.11.2019
6+
# Generated on: 17.11.2019
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'PSWriteHTML.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.0.62'
15+
ModuleVersion = '0.0.63'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Desktop', 'Core'
@@ -51,7 +51,7 @@
5151
# ProcessorArchitecture = ''
5252

5353
# Modules that must be imported into the global environment prior to importing this module
54-
RequiredModules = @(@{ModuleName = 'PSSharedGoods'; GUID = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'; ModuleVersion = '0.0.106'; })
54+
RequiredModules = @(@{ModuleName = 'PSSharedGoods'; GUID = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'; ModuleVersion = '0.0.107'; })
5555

5656
# Assemblies that must be loaded prior to importing this module
5757
# RequiredAssemblies = @()

Public/Email.ps1

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function Email {
2-
[CmdLetBinding(SupportsShouldProcess = $True)]
2+
[CmdLetBinding()]
33
param(
44
[Parameter(Mandatory = $false, Position = 0)][ScriptBlock] $Email,
55
[string[]] $To,
@@ -21,9 +21,10 @@ function Email {
2121
[ValidateSet('None', 'OnSuccess', 'OnFailure', 'Delay', 'Never')] $DeliveryNotifications = 'None',
2222
[string] $Encoding = 'Unicode',
2323
[string] $FilePath,
24-
[bool] $Supress = $true
24+
[bool] $Supress = $true,
25+
[switch] $WhatIf
2526
)
26-
$StartTime = Start-TimeLog
27+
$StartTime = [System.Diagnostics.Stopwatch]::StartNew()
2728
$ServerParameters = [ordered] @{
2829
From = $From
2930
To = $To
@@ -107,13 +108,12 @@ function Email {
107108
}
108109
}
109110

110-
$MailSentTo = "To: $($ServerParameters.To -join ', '); CC: $($ServerParameters.CC -join ', '); BCC: $($ServerParameters.BCC -join ', ')".Trim()
111-
if ($pscmdlet.ShouldProcess("$MailSentTo", "Email")) {
112-
$EmailOutput = Send-Email -EmailParameters $ServerParameters -Body ($Body -join '') -Attachment $Attachments
113-
if (-not $Supress) {
114-
$EmailOutput
115-
}
111+
#$MailSentTo = "To: $($ServerParameters.To -join ', '); CC: $($ServerParameters.CC -join ', '); BCC: $($ServerParameters.BCC -join ', ')".Trim()
112+
$EmailOutput = Send-Email -EmailParameters $ServerParameters -Body ($Body -join '') -Attachment $Attachments -WhatIf:$WhatIf
113+
if (-not $Supress) {
114+
$EmailOutput
116115
}
116+
117117
$EndTime = Stop-TimeLog -Time $StartTime -Option OneLiner
118118
Write-Verbose "Email - Time to send: $EndTime"
119119
}

Public/EmailBody.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,20 @@ function EmailBody {
4949
if ($FontWeight) {
5050
$newHTMLSplat.FontWeight = $FontWeight
5151
}
52+
<#
5253
[bool] $SpanRequired = $false
5354
foreach ($Entry in $newHTMLSplat.GetEnumerator()) {
5455
if (($Entry.Value | Measure-Object).Count -gt 0) {
5556
$SpanRequired = $true
5657
break
5758
}
5859
}
60+
#>
61+
if ($newHTMLSplat.Count -gt 0) {
62+
$SpanRequired = $true
63+
} else {
64+
$SpanRequired = $false
65+
}
5966
if ($SpanRequired) {
6067
New-HTMLSpanStyle @newHTMLSplat {
6168
Invoke-Command -ScriptBlock $EmailBody

0 commit comments

Comments
 (0)