Skip to content

Conversation

@natosullivan
Copy link
Contributor

@natosullivan natosullivan commented Dec 9, 2019

The below code loops indefinitely until the call depth limit is reached:

Email -Port 25 {
        EmailHeader {
            EmailFrom -Address 'test@test.com'
            EmailTo -Addresses "test@test.net"
            EmailServer -Server 'mail.test.com'
            EmailOptions -Priority High -DeliveryNotifications Never
            EmailSubject -Subject 'This is a test email'
        }
        EmailBody -FontFamily 'Calibri' -Size 15 {
            EmailTextBox -FontSize 18 -TextDecoration underline -FontWeight Bold {
                "Test Email"
            }
            EmailText -LineBreak
            EmailList {
                EmailListItem -Text "NotNull"
            }
        }
    } -Supress:$false

Looks to be caused by the script block variables in EmailList and New-HTMLEmailList being named the same, causing the Invoke-Command to create a loop.

Resolved by changing the script block variable name in New-HTMLEmailList to $HTMLListItems

@PrzemyslawKlys
Copy link
Member

Changing the variable name without changing params

[ScriptBlock]$ListItems,

Is going to break that function. The proper fix is to merge New-HTMLList with EmailList by making EmailList an alias. Now that emailimo is merged into PSWriteHTML some stuff is doubled.

@PrzemyslawKlys
Copy link
Member

I've tested this by just running the old code and it never returned error but than the email that arrived didn't had that EmailList. I did a test change per your suggestion

image

And it seems to fix the issue. But I believe we should get rid of EmailList and just make it an alias. Will you fix it?

@natosullivan
Copy link
Contributor Author

That is a much cleaner way to resolve this, I have added the alias to New-HTMLList.

@PrzemyslawKlys PrzemyslawKlys merged commit d3ac923 into EvotecIT:master Dec 9, 2019
@PrzemyslawKlys
Copy link
Member

Looks good. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants