IAdmServiceMailSettings
The IAdmServiceMailSettings interface is used to manage the outgoing mail settings of Adaxes service.
Inheritance: IUnknown
To get the IAdmServiceMailSettings interface, bind to the Service Settings container using the ServiceSettings alias and then get the value of the MailSettings property.
How
- 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) # Get mail settings. $mailSettings = $serviceSettings.MailSettings - 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); // Get mail settings. IAdmServiceMailSettings mailSettings = serviceSettings.MailSettings; } }
Methods
-
Method
-
Description
-
Save()
-
Saves the 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 emails.
-
Port
-
Gets or sets the port of the SMTP server used to send emails.
-
EnableSsl
-
Gets or sets a value indicating whether to enable SSL-encrypted connection with the SMTP server used to send emails.
-
SmtpAuth
-
Gets or sets the credentials that will be used to authenticate against the SMTP server.
-
From
-
Gets or sets the email address from which the emails will be sent.
-
DefaultCredentials
-
This property is deprecated and should not be used. Gets or sets a value indicating whether Adaxes will send emails using the specified credentials.
-
UserName
-
This property is deprecated and should not be used. Gets or sets the username that will be used to send emails.
-
Password
-
This property is deprecated and should not be used. Gets or sets the password to use with the username specified in the
UserNameproperty.
Details
Save()
Saves the mail settings.
void Save()
Examples
The following code sample changes the email address from which 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 – the recipient's email address.
- subject – the email subject.
- textBody – the body of the email. This parameter can be set to
null. - htmlBody – the body of the email in the HTML format. This parameter can be set to
null. - from – the address from which the email will be sent. If the parameter is set to
null, the email address specified in theFromproperty will be used. - cc – 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 – a list of comma separated email addresses that receive a copy of the email but will not be listed as recipients of the message. This parameter can be set to
null.
Examples
The following code sample sends an email to the specified recipient.
- 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
- recipientEmail – the email address where 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 emails.
- Type:
- string
- Access:
- Read/Write
Port
Gets or sets the port of the SMTP server used to send emails.
- Type:
- int
- Access:
- Read/Write
EnableSsl
Gets or sets a value indicating whether to enable SSL-encrypted connection with the SMTP server.
- Type:
- bool
- Access:
- Read/Write
Remarks
Set this property to true only if your SMTP server demands it.
If this property is set to false, it doesn't mean the connection will be unencrypted. Adaxes will use TLS, which is essentially an upgraded version of SSL.
SmtpAuth
Gets or sets the credentials that will be used to authenticate against the SMTP server.
- Type:
- IAdmSmtpAuth
- Access:
- Read/Write
Examples
The following code sample updates the account that the Adaxes service will use to send emails.
- 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) # Create the credentials object. $credentials = New-Object "Softerra.Adaxes.Management.AdmSmtpBasicAuth" $credentials.UserName = "admin@example.com" $credentials.Password = "Password" # Update credentials. $serviceSettings.MailSettings.SmtpAuth = $credentials $serviceSettings.MailSettings.Save() - C#
-
using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.Management; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; using Softerra.Adaxes.Management; 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); // Create the credentials object. IAdmSmtpBasicAuth credentials = new AdmSmtpBasicAuth(); credentials.UserName = "admin@example.com"; credentials.Password = "Password"; // Update credentials. serviceSettings.MailSettings.SmtpAuth = credentials; serviceSettings.MailSettings.Save(); } }
From
Gets or sets the email address from which emails will be sent.
- Type:
- string
- Access:
- Read/Write
DefaultCredentials
This property is deprecated and should not be used.
Gets or sets a value indicating whether Adaxes will send emails using the specified credentials.
- Type:
- bool
- Access:
- Read/Write
UserName
This property is deprecated and should not be used.
Gets or sets the username that will be used to send emails. Setting this property takes effect only if the DefaultCredentials property is set to true.
- Type:
- string
- Access:
- Read/Write
Password
This property is deprecated and should not be used.
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
Requirements
Minimum required version: 2025.1