SMTPEventConsumer

SMTPEvent Consumer

The SMTPEventConsumer class sends an email message by using Simple Mail Transfer Protocol (SMTP) each time an event is delivered to it.

On this page

Main example

List instances

# All instances of SMTPEventConsumer, with the main properties
Get-CimInstance -ClassName SMTPEventConsumer -Namespace 'root/subscription' |
    Select-Object -Property Name, BccLine, CcLine, FromLine

Examples

Filter with WQL

# WQL filter evaluated by the provider: names starting with "a" (the WQL wildcard is %)
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Filter    = "Name LIKE 'a%'"
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, BccLine, CcLine, FromLine

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

Query a remote computer (CIM session)

review before running
# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
    $cimParameters = @{
        CimSession = $cimSession
        ClassName  = 'SMTPEventConsumer'
        Namespace  = 'root/subscription'
    }
    Get-CimInstance @cimParameters |
        Select-Object -Property Name, BccLine, CcLine, FromLine
} finally {
    Remove-CimSession -CimSession $cimSession
}

WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.

Show the class structure

# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName SMTPEventConsumer -Namespace 'root/subscription'
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

Properties

13 of 13 properties
NameTypeAccessDescription
BccLinestringread

A list of addresses, separated by a comma or semicolon, in the format of a standard string template to which the message is sent as a blind carbon copy. For more information, see the Remarks section of this topic.

Code
# Value of BccLine for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'BccLine')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, BccLine
CcLinestringread

A list of addresses, separated by a comma or semicolon, in the format of a standard string template to which the message is sent as a carbon copy. For more information, see the Remarks section of this topic.

Code
# Value of CcLine for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'CcLine')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, CcLine
CreatorSIDuint8[]read

Security identifier (SID) that uniquely identifies the user who creates a filter. WMI stores the SID of the user who creates an instance of __EventConsumer or the Administrator SID, depending on the operating system. For more information, see Binding an Event Filter with a Logical Consumer and Monitoring and Responding to Events with Standard Consumers.

Code
# Value of CreatorSID for each instance
# CreatorSID is an array: -ExpandProperty returns its items one by one
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = 'CreatorSID'
}
Get-CimInstance @cimParameters |
    Select-Object -ExpandProperty CreatorSID
FromLinestringread

From line of an email message in the format of a standard string template. If NULL, a From line is constructed in the form of "WinMgmt@*MachineName*".

Code
# Value of FromLine for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'FromLine')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, FromLine
HeaderFieldsstring[]read

Array of header fields that are inserted into an email message without interpretation.

Code
# Value of HeaderFields for each instance
# HeaderFields is an array: -ExpandProperty returns its items one by one
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = 'HeaderFields'
}
Get-CimInstance @cimParameters |
    Select-Object -ExpandProperty HeaderFields
MachineNamestringread

Name of the computer to which Windows Management Instrumentation (WMI) sends events.

Code
# Value of MachineName for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'MachineName')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, MachineName
MaximumQueueSizeuint32read

Maximum queue for a specific consumer, in bytes.

Code
# Value of MaximumQueueSize for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'MaximumQueueSize')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, MaximumQueueSize
Messagestringread

Standard string template that contains the body of an email message.

Code
# Value of Message for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'Message')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, Message
Name keystringread

Unique identifier for the event consumer.

Code
# Value of Name for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = 'Name'
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name
ReplyToLinestringread

Reply-to line of an email message in the format of a standard string template. If NULL, no Reply-to line is used.

Code
# Value of ReplyToLine for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'ReplyToLine')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, ReplyToLine
SMTPServerstringread

Name of the SMTP server through which an email is sent. Permissible names are an IP address, or a DNS or NetBIOS name. This property cannot be NULL.

Code
# Value of SMTPServer for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'SMTPServer')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, SMTPServer
Subjectstringread

Standard string template that contains the subject of an email message.

Code
# Value of Subject for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'Subject')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, Subject
ToLinestringread

A list of addresses, separated by a comma or semicolon, in the format of a standard string template that identifies where the message is to be sent. For more information, see the Remarks section of this topic.

Code
# Value of ToLine for each instance
$cimParameters = @{
    ClassName = 'SMTPEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'ToLine')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, ToLine

Remarks

The SMTPEventConsumer class is derived from the __EventConsumer abstract class.

Some of the ToLine, CcLine, or BccLine properties can be NULL, but they cannot all be NULL.

Receiving an error return code from the SMTP service is considered a failure.

Inheritance

Superclass chain

  1. __SystemClass
  2. __IndicationRelated
  3. __EventConsumer
  4. SMTPEventConsumer

Known subclasses

No known subclass.

Requirements

Namespace
root/subscription
Minimum client
Windows Vista
Minimum server
Windows Server 2008
MOF file
Smtpcons.mof
DLL
Smtpcons.dll
Class qualifiers

AMENDMENT

Microsoft source

Source: Microsoft Learn

Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.