IAdmSendSmsSettings
The IAdmSendSmsSettings interface is used to manage the SMS settings of Adaxes service.
Inheritance: IUnknown
To use the IAdmSendSmsSettings interface:
Bind to the SMS Settings container using the SmsSettings alias, then create an instance of the AdmSendSmsSettings class, and load the settings from the settings container into the class properties.
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 container. $smsSettingsPath = $service.Backend.GetConfigurationContainerPath("SmsSettings") $smsSettingsContainer = $service.OpenObject($smsSettingsPath, $null, $null, 0) # Create an AdmSendSmsSettings instance and load SMS settings. $sendSmsSettings = New-Object "Softerra.Adaxes.Management.AdmSendSmsSettings" $sendSmsSettings.Load($smsSettingsContainer) - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Management; using Softerra.Adaxes.Interop.Adsi; 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 container. string smsSettingsPath = service.Backend.GetConfigurationContainerPath("SmsSettings"); IAdmTop smsSettingsContainer = (IAdmTop)service.OpenObject(smsSettingsPath, null, null, 0); // Create an AdmSendSmsSettings instance and load SMS settings. AdmSendSmsSettings sendSmsSettings = new AdmSendSmsSettings(); sendSmsSettings.Load(smsSettingsContainer); } }
Methods
Properties
-
Property
-
Description
-
Enabled
-
Gets or sets a value that indicates whether sending SMS messages is enabled.
-
MobileNumberProperty
-
Gets or sets the name of the directory object property that stores mobile phone numbers.
-
MessageMaxLength
-
Gets or sets the maximum allowed length of SMS messages.
-
GatewaySettings
-
Gets or sets SMS gateway settings.
Details
Load()
Loads SMS settings from the specified directory object.
void Load(IAdmTop object)
Parameters
By default, the object parameter should refer to the SMS Settings container.
Examples
The following code sample outputs the name of the property used to store mobile phone numbers.
- 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 container. $smsSettingsPath = $service.Backend.GetConfigurationContainerPath("SmsSettings") $smsSettingsContainer = $service.OpenObject($smsSettingsPath, $null, $null, 0) # Create an AdmSendSmsSettings instance and load SMS settings. $sendSmsSettings = New-Object "Softerra.Adaxes.Management.AdmSendSmsSettings" $sendSmsSettings.Load($smsSettingsContainer) # Output the property name. Write-Host "Property used to store mobile phone numbers:" + $sendSmsSettings.MobileNumberProperty - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Management; using Softerra.Adaxes.Interop.Adsi; 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 container. string smsSettingsPath = service.Backend.GetConfigurationContainerPath("SmsSettings"); IAdmTop smsSettingsContainer = (IAdmTop)service.OpenObject(smsSettingsPath, null, null, 0); // Create an AdmSendSmsSettings instance and load SMS settings. AdmSendSmsSettings sendSmsSettings = new AdmSendSmsSettings(); sendSmsSettings.Load(smsSettingsContainer); // Output the property name. Console.WriteLine( "Property that is used to store mobile phone numbers: {0}", sendSmsSettings.MobileNumberProperty); } }
Save()
Saves SMS settings to the specified directory object.
void Save(IAdmTop object)
Parameters
By default, the object parameter should refer to the SMS Settings container.
Remarks
To save the changes to the directory, call IADs::SetInfo on the object after calling this method.
Examples
The following code sample sets the maximum length of SMS messages to 200.
- 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 container. $smsSettingsPath = $service.Backend.GetConfigurationContainerPath("SmsSettings") $smsSettingsContainer = $service.OpenObject($smsSettingsPath, $null, $null, 0) # Create an AdmSendSmsSettings instance and load SMS settings. $sendSmsSettings = New-Object "Softerra.Adaxes.Management.AdmSendSmsSettings" $sendSmsSettings.Load($smsSettingsContainer) # Set the maximum SMS message length. $sendSmsSettings.MessageMaxLength = 200 # Save the changes. $sendSmsSettings.Save($smsSettingsContainer) $smsSettingsContainer.SetInfo() - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Management; using Softerra.Adaxes.Interop.Adsi; 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 container. string smsSettingsPath = service.Backend.GetConfigurationContainerPath("SmsSettings"); IAdmTop smsSettingsContainer = (IAdmTop)service.OpenObject(smsSettingsPath, null, null, 0); // Create an AdmSendSmsSettings instance and load SMS settings. AdmSendSmsSettings sendSmsSettings = new AdmSendSmsSettings(); sendSmsSettings.Load(smsSettingsContainer); // Set the maximum SMS message length. sendSmsSettings.MessageMaxLength = 200; // Save the changes. sendSmsSettings.Save(smsSettingsContainer); smsSettingsContainer.SetInfo(); } }
Enabled
Gets or sets a value that indicates whether sending SMS messages is enabled.
- Type:
- bool
- Access:
- Read/Write
MobileNumberProperty
Gets or sets the name of the directory object property that stores mobile phone numbers.
- Type:
- string
- Access:
- Read/Write
MessageMaxLength
Gets or sets the maximum allowed length of SMS messages. Messages that exceed the limit are truncated by Adaxes.
- Type:
- int
- Access:
- Read/Write
GatewaySettings
Gets or sets SMS gateway settings.
- Type:
- IAdmSendSmsGatewaySettings
- Access:
- Read/Write
Remarks
This property supports different interfaces, depending on the gateway type specified in the GatewayType property of the IAdmSendSmsGatewaySettings property.
To set SMS gateway settings, you need to create an instance of a class that implements the corresponding interface – either AdmSendSmsEmailGatewaySettings or AdmSendSmsHttpGatewaySettings.
Examples
The following code sample outputs the HTTP request URL if SMS gateway type is HTTP to SMS.
- 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 container. $smsSettingsPath = $service.Backend.GetConfigurationContainerPath("SmsSettings") $smsSettingsContainer = $service.OpenObject($smsSettingsPath, $null, $null, 0) # Create an AdmSendSmsSettings instance and load SMS settings. $sendSmsSettings = New-Object "Softerra.Adaxes.Management.AdmSendSmsSettings" $sendSmsSettings.Load($smsSettingsContainer) # Get SMS gateway provider settings. $gatewaySettings = $sendSmsSettings.GatewaySettings if ($gatewaySettings.GatewayType -eq "ADM_SMSGATEWAYTYPE_HTTP") { Write-Host "URL:" $gatewaySettings.Url } - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Management; using Softerra.Adaxes.Interop.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 container. string smsSettingsPath = service.Backend.GetConfigurationContainerPath("SmsSettings"); IAdmTop smsSettingsContainer = (IAdmTop)service.OpenObject(smsSettingsPath, null, null, 0); // Create an AdmSendSmsSettings instance and load SMS settings. AdmSendSmsSettings sendSmsSettings = new AdmSendSmsSettings(); sendSmsSettings.Load(smsSettingsContainer); // Get SMS gateway provider settings. IAdmSendSmsGatewaySettings gatewaySettings = sendSmsSettings.GatewaySettings; if (gatewaySettings is IAdmSendSmsHttpGatewaySettings httpGatewaySettings) { Console.WriteLine("URL: " + httpGatewaySettings.Url); } } }
The following code sample configures the settings of an Email to SMS gateway provider.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Create an instance of the AdmSendSmsSettings class. $sendSmsSettings = New-Object "Softerra.Adaxes.Management.AdmSendSmsSettings" # Enable SMS. $sendSmsSettings.Enabled = $true # Create an instance of the AdmSendSmsEmailGatewaySettings class. $emailGatewaySettings = New-Object "Softerra.Adaxes.Management.AdmSendSmsEmailGatewaySettings" # Specify the email address in the To field. $emailGatewaySettings.To = "%mobilenumber%@example.com" # Specify the body. $emailGatewaySettings.Body = "Message:%smstext%" # Set SMS gateway settings. $sendSmsSettings.GatewaySettings = $emailGatewaySettings # Save the changes. $smsSettingsPath = $service.Backend.GetConfigurationContainerPath("SmsSettings") $smsSettingsContainer = $service.OpenObject($smsSettingsPath, $null, $null, 0) $sendSmsSettings.Save($smsSettingsContainer) $smsSettingsContainer.SetInfo() - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Management; using Softerra.Adaxes.Interop.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"); // Create an instance of the AdmSendSmsSettings class. AdmSendSmsSettings sendSmsSettings = new AdmSendSmsSettings(); // Enable SMS. sendSmsSettings.Enabled = true; // Create an instance of the AdmSendSmsEmailGatewaySettings class. AdmSendSmsEmailGatewaySettings emailGatewaySettings = new AdmSendSmsEmailGatewaySettings(); // Specify the email address in the To field. emailGatewaySettings.To = "%mobilenumber%@example.com"; // Specify the body. emailGatewaySettings.Body = "Message:%smstext%"; // Set SMS gateway settings. sendSmsSettings.GatewaySettings = emailGatewaySettings; // Save the changes. string smsSettingsPath = service.Backend.GetConfigurationContainerPath("SmsSettings"); IAdmTop smsSettingsContainer = (IAdmTop)service.OpenObject(smsSettingsPath, null, null, 0); sendSmsSettings.Save(smsSettingsContainer); smsSettingsContainer.SetInfo(); } }
Requirements
Minimum required version: 2017.1