Skip to content
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

Issue with sending email "Error sending message: Email Server Host is not set." #54

Open
steve-work opened this issue Jun 18, 2019 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@steve-work
Copy link

steve-work commented Jun 18, 2019

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.

@PrzemyslawKlys
Copy link
Member

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.

@steve-work
Copy link
Author

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'
            }
        }
    }

@PrzemyslawKlys
Copy link
Member

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

@PrzemyslawKlys PrzemyslawKlys added the bug Something isn't working label Jun 18, 2019
@PrzemyslawKlys PrzemyslawKlys self-assigned this Jun 18, 2019
PrzemyslawKlys added a commit that referenced this issue Aug 19, 2019
@PrzemyslawKlys
Copy link
Member

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.

PrzemyslawKlys added a commit that referenced this issue Aug 19, 2019
PrzemyslawKlys added a commit that referenced this issue Aug 19, 2019
@PrzemyslawKlys
Copy link
Member

This was autoclosed by github. It seems commit with "fixes" closes issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants