Mail 属性

获取与 SQL Server 的实例关联的 Microsoft SQL Mail 服务。

命名空间:  Microsoft.SqlServer.Management.Smo
程序集:  Microsoft.SqlServer.Smo(在 Microsoft.SqlServer.Smo.dll 中)

语法

声明
<SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)> _
Public ReadOnly Property Mail As SqlMail
    Get
用法
Dim instance As Server
Dim value As SqlMail

value = instance.Mail
[SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)]
public SqlMail Mail { get; }
[SfcObjectAttribute(SfcObjectRelationship::Object, SfcObjectCardinality::One)]
public:
property SqlMail^ Mail {
    SqlMail^ get ();
}
[<SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)>]
member Mail : SqlMail
function get Mail () : SqlMail

属性值

类型:Microsoft.SqlServer.Management.Smo.Mail. . :: . .SqlMail
一个 SqlMail 对象,该对象指定与 SQL Server 实例关联的 SQL Mail 服务。

示例

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server()
'Define the Database Mail service with a SqlMail object variable and reference it using the Server Mail property.
Dim sm As SqlMail
sm = srv.Mail
'Define and create a mail account by supplying the Database Mail service, name, description, display name, and email address arguments in the constructor.
Dim a As MailAccount
a = New MailAccount(sm, "Adventure Works Administrator", "Adventure Works Automated Mailer", "Mail account for administrative e-mail.", "dba@Adventure-Works.com")
a.Create()

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$sm = $srv.Mail
$a = new-object Microsoft.SqlServer.Management.Smo.Mail.MailAccount($sm, "Adventure Works Administrator", "AdventureWorks2008R2 Automated Mailer", "Mail account for administrative e-mail.", "dba@Adventure-Works.com")
$a.Create()