IAdmServiceMailSettings
The IAdmServiceMailSettings interface is used to manage outgoing mail settings of Adaxes service.
Inheritance: IUnknown
To get the IAdmServiceMailSettings interface:
- Bind to the Service Settings container using the "ServiceSettings" alias.
- Use the IAdmServiceSettings::MailSettings property to get the IAdmServiceMailSettings interface.
Methods
-
Method
-
Description
-
Save()
-
Saves the outgoing mail settings.
-
SendMail()
-
Sends an email to the specified recipient.
-
TestSettings()
-
Sends a test message to the given email address.
Properties
-
Property
-
Description
-
Host
-
Gets or sets the fully qualified domain name (FQDN) of an SMTP server that will be used to send outgoing emails.
-
Port
-
Gets or sets the port of the SMTP server used to send outgoing emails.
-
EnableSsl
-
Gets or sets a value indicating whether to enable encrypted connection (SSL) with the SMTP server used to send outgoing emails.
-
DefaultCredentials
-
Gets or sets a value indicating whether Adaxes will send outgoing emails using the specified credentials.
-
UserName
-
Gets or sets the username that will be used to send outgoing emails.
-
Password
-
Gets or sets the password to use with the username specified in the
UserName
property. -
From
-
Gets or sets the email address from which outgoing emails will be sent.
Details
Save()
Saves the outgoing mail settings.
void Save()
Examples
The following code sample changes the email address from which outgoing emails will be sent.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the 'Service Settings' container $wellknownContainerPath = $service.Backend.GetConfigurationContainerPath("ServiceSettings") $serviceSettings = $service.OpenObject($wellknownContainerPath, $null, $null, 0) $mailSettings = $serviceSettings.MailSettings # Update mail settings $mailSettings.From = "user@company.com" $mailSettings.Save()
- C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Management; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the 'Service Settings' container string wellknownContainerPath = service.Backend.GetConfigurationContainerPath( "ServiceSettings"); IAdmServiceSettings serviceSettings = (IAdmServiceSettings) service.OpenObject( wellknownContainerPath, null, null, 0); IAdmServiceMailSettings mailSettings = serviceSettings.MailSettings; // Update mail settings mailSettings.From = "user@company.com"; mailSettings.Save(); } }
SendMail()
Sends an email to the specified recipient.
void SendMail(string to,
string subject,
string textBody,
string htmlBody,
string from,
string cc,
string bcc)
Parameters
- to - Specifies the recipient's email address.
- subject - Specifies the subject of the email.
- textBody - Specifies the body of the email. This parameter can be set to
null
. - htmlBody - Specifies the body of the email in the HTML format. This parameter can be set to
null
. - from - Specifies the address from which the email will be sent. If the parameter is set to
null
, the email address specified in the From property will be used. - cc - Specifies a list of comma separated email addresses to which a carbon copy (CC) of the email message will be sent. This parameter can be set to
null
. - bcc - Specifies a list of comma separated email addresses that receive a copy of the mail but are not listed as recipients of the message. This parameter can be set to
null
.
Examples
The following code sample changes the email address from which outgoing emails will be sent.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the 'Service Settings' container $wellknownContainerPath = $service.Backend.GetConfigurationContainerPath("ServiceSettings") $serviceSettings = $service.OpenObject($wellknownContainerPath, $null, $null, 0) $mailSettings = $serviceSettings.MailSettings # Email settings $to = "jdoe@company.com, jsmith@company.com" $subject = "My Subject" $textBody = "My Message" $from = "fromaddress@company.com" $cc = "ccaddress@company.com" $bcc = "bccaddress@company.com" # Send mail $mailSettings.SendMail($to, $subject, $textBody, $null, $from, $cc, $bcc)
- C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Management; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the 'Service Settings' container string wellknownContainerPath = service.Backend.GetConfigurationContainerPath( "ServiceSettings"); IAdmServiceSettings serviceSettings = (IAdmServiceSettings) service.OpenObject( wellknownContainerPath, null, null, 0); IAdmServiceMailSettings mailSettings = serviceSettings.MailSettings; // Email settings string to = "jdoe@company.com, jsmith@company.com"; string subject = "My Subject"; string textBody = "My Message"; string from = "fromaddress@company.com"; string cc = "ccaddress@company.com"; string bcc = "bccaddress@company.com"; // Send mail mailSettings.SendMail(to, subject, textBody, null, from, cc, bcc); } }
TestSettings()
Sends a test message to the given email address.
void TestSettings(string recipientEmail)
Parameters
The recipientEmail parameter specifies the email address to which a test message will be sent.
Host
Gets or sets the fully qualified domain name (FQDN) of an SMTP server that will be used to send outgoing emails.
- Type:
- string
- Access:
- Read/Write
Port
Gets or sets the port of the SMTP server used to send outgoing emails.
- Type:
- int
- Access:
- Read/Write
EnableSsl
Gets or sets a value indicating whether to enable encrypted connection (SSL) with the SMTP server used to send outgoing emails.
- Type:
- bool
- Access:
- Read/Write
DefaultCredentials
This property is deprecated and should not be used.
Gets or sets a value indicating whether Adaxes will send outgoing emails using the specified credentials.
- Type:
- bool
- Access:
- Read/Write
UserName
Gets or sets the username that will be used to send outgoing emails. Setting this property takes effect only if the DefaultCredentials
property is set to true
.
- Type:
- string
- Access:
- Read/Write
Password
Gets or sets the password to use with the username specified in the UserName
property. Setting this property takes effect only if the DefaultCredentials
property is set to true
.
- Type:
- string
- Access:
- Read/Write
From
Gets or sets the email address from which outgoing emails will be sent.
- Type:
- string
- Access:
- Read/Write
Requirements
Minimum required version: 2009.1