Issue with sending email "Error sending message: Email Server Host is not set."
steve-work opened this issue · 5 comments
I'm using version 2.0.11, and have set up event forwarding.
Events are coming through and I've set up the task to trigger RunMe-TriggerOnEvents.ps1.
I've configured my email settings in RunMe-TriggerOnEvents.ps1:
From = 'ADChanges@XXXX.com'
To = 'steve-work@XXXX.com'
CC = ''
BCC = ''
ReplyTo = ''
Server = "smtp.XXXX.local"
Password = ''
PasswordAsSecure = $false
PasswordFromFile = $false
Port = '25'
Login = ''
EnableSSL = 1
Encoding = 'Unicode'
Subject = 'Event Changes for period <> to <>'
Priority = 'Low'
smtp.XXXX.local is a working internal SMTP relay, which does not require authentication.
When the script gets triggered, nothing happens. I've tried manually running it with the same parameters and get the following errors:
[18/06/2019 11:27:15][Info] Prepare email head and body
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\PSSharedGoods\0.0.78\PSSharedGoods.psm1:3561 char:24
+ ... foreach ($style in $FormattingParameters.Styles.GetEnumerator()) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\PSSharedGoods\0.0.78\PSSharedGoods.psm1:3568 char:24
+ ... foreach ($color in $FormattingParameters.Colors.GetEnumerator()) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\PSSharedGoods\0.0.78\PSSharedGoods.psm1:3575 char:24
+ foreach ($links in $FormattingParameters.Links.GetEnumerator()) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
[18/06/2019 11:27:15][Info] Saving report to file: C:\Users\admin.XX\AppData\Local\Temp\PSWinReporting.html
[18/06/2019 11:27:16][Info] Sending email with reports
[18/06/2019 11:27:16][Info] Error sending message: Email Server Host is not set.
Remove-ReportFiles : The term 'Remove-ReportFiles' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\PSWinReportingV2\2.0.11\PSWinReportingV2.psm1:1563 char:21
+ Remove-ReportFiles -KeepReports $false -ReportFil ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Remove-ReportFiles:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have also tried connecting to office 365 with a login name and password, but get the same error.
Well, to me it sounds like you're using the wrong config for the wrong version. Configs described on the blog are for PSWinReporting. PSWinWreportingV2 has different config - https://github.com/EvotecIT/PSWinReporting/blob/master/Examples/RunMe-TriggerOnEvents.ps1 and it's not really described how it works yet. It's much more advanced on what you can do, but you need to be aware of how things work.
Thanks for the quick reply.
I'm using the file: https://github.com/EvotecIT/PSWinReporting/blob/master/Examples/RunMe-TriggerOnEvents.ps1
Here is what I've got on lines 55-93:
Default = @{
Parameters = @{
From = 'adchanges@XXXX.com'
To = 'steve-work@XXXX.com'
CC = ''
BCC = ''
ReplyTo = ''
Server = "smtp.XXXX.local"
Password = ''
PasswordAsSecure = $false
PasswordFromFile = $false
Port = '25'
Login = ''
EnableSSL = 0
Encoding = 'Unicode'
Subject = 'Event Changes for period <<DateFrom>> to <<DateTo>>'
Priority = 'Low'
}
}
High = @{
Parameters = @{
From = 'adchanges@XXXX.com'
To = 'steve-work@XXXX.com'
CC = ''
BCC = ''
ReplyTo = ''
Server = "smtp.XXXX.local"
Password = ''
PasswordAsSecure = $false
PasswordFromFile = $false
Port = '25'
Login = ''
EnableSSL = 0
Encoding = 'Unicode'
Subject = 'Event Changes for period <<DateFrom>> to <<DateTo>>'
Priority = 'High'
}
}
}
Oh, I see. Well, I'll try to ding the root cause. I've not tested this new version lately so I'll give it a go. I'll be in touch
Turns out I've actually never tested emails in PSWinReportingV2 for TriggerOnEvents. I've now fixed that but I want to rewrite some portions of it to use Emailimo I think.
This was autoclosed by github. It seems commit with "fixes" closes issues.