Skip to content

Add Exchange Payload to Profile

This function is used to add a new Exchange payload to the specified profile.

Public Function AddExchangePayloadToProfile
(profileId As Integer, AccountName As String, DomainandUserName As String, Password As String,
EmailAddress As String, ExchangeActiveSyncHost As String, UseSSL As Boolean,PastDaysofMailtoSync As Integer, AllowMove As Boolean,
UseOnlyinMail As Boolean, UseSMIME As Boolean, AllowRecentAddressSyncing As Boolean, Syncinterval As String, SyncEmail As Boolean,
SyncCalendar As Boolean, SyncContacts As Boolean, SyncTasks As Boolean, ByVal changelogComment As String) As Boolean
Parameter Type Description
profileId Integer The Id of the profile to add the payload to. Get it with Get Profiles.
AccountName String Name of the Exchange ActiveSync account. It’s also used as the name of the payload.
DomainandUserName String The user name for the Exchange account, in the format domain\username, for example mydomain.com\$LoginName$. If it’s empty, the device prompts for it when the profile is installed.
Password String Optional. The password of the account. Only use it with encrypted profiles. Use an empty string to leave it out.
EmailAddress String The full email address for the account. If it’s empty, the device prompts for it when the profile is installed. Required for macOS.
ExchangeActiveSyncHost String The host name or IP address of the Exchange server. Required for macOS.
UseSSL Boolean True if the Exchange server uses SSL.
PastDaysofMailtoSync Integer The number of past days of mail to synchronize. Valid values: 0 (no limit), 1, 3, 7, 14, 31.
AllowMove Boolean If True, messages can’t be moved out of this account into another account, and the user can’t forward or reply from another account.
UseOnlyinMail Boolean If True, the account can’t be used to send mail from third-party apps.
UseSMIME Boolean If True, the account supports S/MIME.
AllowRecentAddressSyncing Boolean If True, the account is excluded from syncing of recent addresses.
Syncinterval String How often the device synchronizes with the Exchange server. Valid values: Automatic Push, Manually, 15 minutes, 30 minutes, 60 minutes. Any other value is treated as Automatic Push.
SyncEmail Boolean True to synchronize email.
SyncCalendar Boolean True to synchronize the calendar.
SyncContacts Boolean True to synchronize contacts.
SyncTasks Boolean True to synchronize tasks.
changelogComment String A comment that is added to the changelog entry of the profile.

Returns a boolean value. True if succeeded, false if not. The function returns false if the profileId doesn’t belong to a profile, for example if it’s the Id of a Device Application.

Set oCMS = CreateObject("CapaInstaller.SDK")
Wscript.echo oCMS.SetDatabaseSettings("ServerName", "Capainstaller", False)
Wscript.echo oCMS.SetInstanceManagementPoint("2")
Dim iProfileId : iProfileId = 6
Dim sAccountName : sAccountName = "tre"
Dim sDomainandUserName : sDomainandUserName = "tre@myco.com"
Dim sPassword : sPassword = "1234"
Dim sEmailAddress : sEmailAddress = "tre@myco.com"
Dim sExchangeActiveSyncHost : sExchangeActiveSyncHost = "outlook.office365.com"
Dim bUseSSL : bUseSSL = True
Dim iPastDaysofMailtoSync : iPastDaysofMailtoSync = 14
Dim bAllowMove : bAllowMove = True
Dim bUseOnlyinMail : bUseOnlyinMail = False
Dim bUseSMIME : bUseSMIME = False
Dim bAllowRecentAddressSyncing : bAllowRecentAddressSyncing = True
Dim sSyncinterval : sSyncinterval = "30 minutes"
Dim bSyncEmail : bSyncEmail = True
Dim bSyncCalendar : bSyncCalendar = True
Dim bSyncContacts : bSyncContacts = False
Dim bSyncTasks : bSyncTasks = False
Dim sChangelogComment : sChangelogComment = "Added exchange with sdk"
Wscript.echo "Added Exchange payload: " & oCMS.AddExchangePayloadToProfile(iProfileId, sAccountName, sDomainandUserName, sPassword, sEmailAddress, sExchangeActiveSyncHost, bUseSSL, iPastDaysofMailtoSync, bAllowMove, bUseOnlyinMail, bUseSMIME, bAllowRecentAddressSyncing, sSyncinterval, bSyncEmail, bSyncCalendar, bSyncContacts, bSyncTasks, sChangelogComment)