diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnable.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnable.vb index 4dc67b0b..64f1a337 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnable.vb +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnable.vb @@ -41,42 +41,31 @@ Public Class MailEnable Inherits HostingServiceProviderBase Implements IMailServer - Private Const DOMAIN_PROG_ID As String = "MEAOSM.Domain" - Private Const BLACKLIST_PROG_ID As String = "MEAOSM.Blacklist" - Private Const POSTOFFICE_PROG_ID As String = "MEAOPO.Postoffice" - Private Const LOGIN_PROG_ID As String = "MEAOAU.Login" - Private Const MAILBOX_PROG_ID As String = "MEAOPO.Mailbox" - Private Const MAILLIST_PROG_ID As String = "MEAOLS.List" - Private Const LIST_MEMBER_PROG_ID As String = "MEAOLS.ListMember" - Private Const ADDRESS_MAP_PROG_ID As String = "MEAOAM.AddressMap" - Private Const GROUP_PROG_ID As String = "MEAOPO.Group" - Private Const GROUP_MEMBER_PROG_ID As String = "MEAOPO.GroupMember" - #Region "Domains" - Public Overridable Function GetDomains() As String() Implements IMailServer.GetDomains + Public Overridable Function GetDomains() As String() Implements IMailServer.GetDomains - Dim domainList As List(Of String) = New List(Of String) - Dim po As Object = CreateObject(POSTOFFICE_PROG_ID) + Dim domainList As List(Of String) = New List(Of String) + Dim po As New WebsitePanel.Providers.Mail.MailEnablePostoffice - po.Account = "" - po.Name = "" - po.Status = -1 - If po.FindFirstPostoffice() = 1 Then - Do - domainList.Add(po.Name) - po.Account = "" - po.Name = "" - po.Status = -1 - Loop While po.FindNextPostoffice() = 1 - End If + po.Account = "" + po.Name = "" + po.Status = -1 + If po.FindFirstPostoffice() = 1 Then + Do + domainList.Add(po.Name) + po.Account = "" + po.Name = "" + po.Status = -1 + Loop While po.FindNextPostoffice() = 1 + End If - Return domainList.ToArray() + Return domainList.ToArray() - End Function + End Function Public Overridable Function DomainExists(ByVal domainName As String) As Boolean Implements IMailServer.DomainExists - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain ResetDomain(domain) domain.AccountName = domainName @@ -87,7 +76,7 @@ Public Class MailEnable Public Overridable Function GetDomain(ByVal domainName As String) As MailDomain Implements IMailServer.GetDomain Dim info As MailDomain = Nothing - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain ResetDomain(domain) domain.AccountName = domainName @@ -104,7 +93,7 @@ Public Class MailEnable Public Overridable Sub CreateDomain(ByVal domainInfo As MailDomain) Implements IMailServer.CreateDomain 'create a new postoffice for each account - Dim postoffice As Object = CreateObject(POSTOFFICE_PROG_ID) + Dim postoffice As New WebsitePanel.Providers.Mail.MailEnablePostoffice postoffice.Account = domainInfo.Name postoffice.Name = domainInfo.Name postoffice.Status = IIf((domainInfo.Enabled), 1, 0) @@ -113,7 +102,7 @@ Public Class MailEnable Throw New Exception("Postoffice creation failedNot ") End If - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain domain.AccountName = domainInfo.Name domain.DomainName = domainInfo.Name domain.DomainRedirectionHosts = domainInfo.RedirectionHosts @@ -127,7 +116,7 @@ Public Class MailEnable Dim blackListedDomain As String For Each blackListedDomain In domainInfo.BlackList - Dim blacklist As Object = CreateObject(BLACKLIST_PROG_ID) + Dim blacklist As New WebsitePanel.Providers.Mail.MailEnableDomainBlacklist blacklist.Account = domainInfo.Name blacklist.Status = 1 blacklist.TargetDomainName = domainInfo.Name @@ -139,7 +128,7 @@ Public Class MailEnable End Sub Public Overridable Sub UpdateDomain(ByVal info As MailDomain) Implements IMailServer.UpdateDomain - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain domain.AccountName = info.Name domain.DomainName = info.Name domain.DomainRedirectionHosts = String.Empty @@ -148,9 +137,22 @@ Public Class MailEnable domain.Status = -1 If (domain.GetDomain() = 1) Then + Dim newStatus As Integer = IIf(info.Enabled, 1, 0) Dim newRedirectionStatus As Integer = IIf(info.RedirectionActive, 1, 0) + 'redirection status has 3 states, so we don't use redirectionaction + '0=off, 1=on, 2=on for authenticated only + If info("MailEnable_SmartHostEnabled") Then + If info("MailEnable_SmartHostAuth") Then + newRedirectionStatus = 2 + Else + newRedirectionStatus = 1 + End If + Else + newRedirectionStatus = 0 + End If + domain.EditDomain( _ info.Name, _ newStatus, _ @@ -161,12 +163,13 @@ Public Class MailEnable ' ' Update the Catch All Account ' - Dim oAddressMap As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim oAddressMap As New WebsitePanel.Providers.Mail.MailEnableAddressMap oAddressMap.Account = info.Name ' account oAddressMap.DestinationAddress = "" oAddressMap.SourceAddress = "[SMTP:*@" & info.Name & "]" oAddressMap.Scope = "" + If info.CatchAllAccount = "" Then ' things are tricky here because we want to change it so we know what we are deleting oAddressMap.SourceAddress = "[SMTP:*@" & info.Name & "]" @@ -175,7 +178,7 @@ Public Class MailEnable ' ' Change its value if it exists ' - If oAddressMap.EditAddressMap(info.Name, "[DELETE:ME]", "[DELETE:ME]", "0") Then + If oAddressMap.EditAddressMap(info.Name, "[DELETE:ME]", "[DELETE:ME]", "0", oAddressMap.Status) Then oAddressMap.Account = info.Name oAddressMap.DestinationAddress = "[DELETE:ME]" oAddressMap.SourceAddress = "[DELETE:ME]" @@ -187,7 +190,8 @@ Public Class MailEnable Dim NewSourceAddress As String = "[SMTP:*@" & info.Name & "]" Dim NewDestinationAddress As String = "[SF:" & info.Name & "/" & GetMailboxName(info.CatchAllAccount) & "]" Dim NewScope As String = "0" - If oAddressMap.EditAddressMap(NewAccount, NewSourceAddress, NewDestinationAddress, NewScope) <> 1 Then + + If oAddressMap.EditAddressMap(NewAccount, NewSourceAddress, NewDestinationAddress, NewScope, 0) <> 1 Then ' ' We need to add it because there was not one defined ' @@ -216,7 +220,7 @@ Public Class MailEnable Dim NewSourceAddress = "[SMTP:postmaster@" & info.Name & "]" Dim NewDestinationAddress = "[SF:" & info.Name & "/" & GetMailboxName(info.PostmasterAccount) & "]" Dim NewScope = "0" - If oAddressMap.EditAddressMap(NewAccount, NewSourceAddress, NewDestinationAddress, NewScope) <> 1 Then + If oAddressMap.EditAddressMap(NewAccount, NewSourceAddress, NewDestinationAddress, NewScope, 0) <> 1 Then ' ' We need to add it because there was not one defined ' @@ -245,7 +249,7 @@ Public Class MailEnable Dim NewSourceAddress = "[SMTP:Abuse@" & info.Name & "]" Dim NewDestinationAddress = "[SF:" & info.Name & "/" & GetMailboxName(info.AbuseAccount) & "]" Dim NewScope = "0" - If oAddressMap.EditAddressMap(NewAccount, NewSourceAddress, NewDestinationAddress, NewScope) <> 1 Then + If oAddressMap.EditAddressMap(NewAccount, NewSourceAddress, NewDestinationAddress, NewScope, 0) <> 1 Then ' ' We need to add it because there was not one defined ' @@ -260,7 +264,7 @@ Public Class MailEnable 'edit blacklists 'delete all the blacklists - Dim blacklist As Object = CreateObject(BLACKLIST_PROG_ID) + Dim blacklist As New WebsitePanel.Providers.Mail.MailEnableDomainBlacklist ResetBlacklist(blacklist) blacklist.Account = info.Name blacklist.TargetDomainName = info.Name @@ -270,7 +274,7 @@ Public Class MailEnable blacklist.RemoveBlacklist() ' initialize blacklist again - blacklist = CreateObject(BLACKLIST_PROG_ID) + blacklist = New WebsitePanel.Providers.Mail.MailEnableDomainBlacklist ResetBlacklist(blacklist) blacklist.Account = info.Name blacklist.TargetDomainName = info.Name @@ -279,7 +283,7 @@ Public Class MailEnable 'add new blacklists Dim blacklistedDomainName As String For Each blacklistedDomainName In info.BlackList - blacklist = CreateObject(BLACKLIST_PROG_ID) + blacklist = New WebsitePanel.Providers.Mail.MailEnableDomainBlacklist blacklist.Account = info.Name blacklist.TargetDomainName = info.Name blacklist.BannedDomainName = blacklistedDomainName @@ -289,18 +293,20 @@ Public Class MailEnable blacklist.AddBlacklist() Next + End If End Sub Public Overridable Sub DeleteDomain(ByVal domainName As String) Implements IMailServer.DeleteDomain 'delete all postoffice logins - Dim login As Object = CreateObject(LOGIN_PROG_ID) + Dim login As New WebsitePanel.Providers.Mail.MailEnableLogin ResetLogin(login) login.Account = domainName login.RemoveLogin() 'delete all the mailboxes - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox + ResetMailbox(mailbox) mailbox.Postoffice = domainName mailbox.RemoveMailbox() @@ -310,7 +316,7 @@ Public Class MailEnable Dim list As MailList For Each list In lists ' remove list members - Dim listMember As Object = CreateObject(LIST_MEMBER_PROG_ID) + Dim listMember As New WebsitePanel.Providers.Mail.MailEnableListMember listMember.AccountName = domainName listMember.ListName = GetMailboxName(list.Name) listMember.Address = "" @@ -319,7 +325,7 @@ Public Class MailEnable listMember.RemoveListMember() ' delete maillist - Dim mailList As Object = CreateObject(MAILLIST_PROG_ID) + Dim mailList As New WebsitePanel.Providers.Mail.MailEnableList ResetMaillist(mailList) mailList.AccountName = domainName mailList.ListName = GetMailboxName(list.Name) @@ -331,14 +337,14 @@ Public Class MailEnable Dim group As MailGroup For Each group In groups ' remove group members - Dim groupMember As Object = CreateObject(GROUP_MEMBER_PROG_ID) + Dim groupMember As New WebsitePanel.Providers.Mail.MailEnableGroupMember groupMember.Postoffice = domainName groupMember.Mailbox = GetMailboxName(group.Name) groupMember.Address = "" groupMember.RemoveGroupMember() ' delete group - Dim objGroup As Object = CreateObject(GROUP_PROG_ID) + Dim objGroup As New WebsitePanel.Providers.Mail.MailEnableGroup ResetGroup(objGroup) objGroup.Postoffice = domainName objGroup.GroupName = GetMailboxName(group.Name) @@ -346,25 +352,25 @@ Public Class MailEnable Next 'delete all address mappings - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap ResetAddressMap(map) map.Account = domainName - map.RemoveAddressMap() + map.RemoveAddressMap(True) 'delete all the blacklists - Dim blacklist As Object = CreateObject(BLACKLIST_PROG_ID) + Dim blacklist As New WebsitePanel.Providers.Mail.MailEnableDomainBlacklist ResetBlacklist(blacklist) blacklist.Account = domainName blacklist.RemoveBlacklist() 'delete all domains - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain ResetDomain(domain) domain.AccountName = domainName domain.RemoveDomain() 'delete postoffice - Dim po As Object = CreateObject(POSTOFFICE_PROG_ID) + Dim po As New WebsitePanel.Providers.Mail.MailEnablePostoffice po.Account = domainName po.Name = domainName po.Host = "" @@ -385,12 +391,24 @@ Public Class MailEnable info.Name = domain.DomainName info.RedirectionHosts = domain.DomainRedirectionHosts info.RedirectionActive = (domain.DomainRedirectionStatus = 1) + + If domain.DomainRedirectionStatus = 2 Then + info("MailEnable_SmartHostAuth") = True + info("MailEnable_SmartHostEnabled") = True + ElseIf domain.DomainRedirectionStatus = 1 Then + info("MailEnable_SmartHostEnabled") = True + info("MailEnable_SmartHostAuth") = False + Else + info("MailEnable_SmartHostEnabled") = false + info("MailEnable_SmartHostAuth") = False + End If + info.Enabled = (domain.Status = 1) ' ' We need to get the catch all account for the domain ' - Dim oAddressMap As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim oAddressMap As New WebsitePanel.Providers.Mail.MailEnableAddressMap oAddressMap.Account = info.Name oAddressMap.DestinationAddress = "" oAddressMap.SourceAddress = "[SMTP:*@" & info.Name & "]" @@ -432,7 +450,7 @@ Public Class MailEnable 'getting black mail list Dim blacklists As ArrayList = New ArrayList - Dim blacklist As Object = CreateObject(BLACKLIST_PROG_ID) + Dim blacklist As New WebsitePanel.Providers.Mail.MailEnableDomainBlacklist blacklist.Account = domain.AccountName blacklist.Host = domain.Host blacklist.TargetDomainName = domain.DomainName @@ -461,7 +479,7 @@ Public Class MailEnable #Region "Domain Aliases" Public Overridable Function DomainAliasExists(ByVal domainName As String, ByVal aliasName As String) As Boolean Implements IMailServer.DomainAliasExists - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain ResetDomain(domain) domain.AccountName = domainName @@ -472,7 +490,7 @@ Public Class MailEnable Public Overridable Function GetDomainAliases(ByVal domainName As String) As String() Implements IMailServer.GetDomainAliases Dim aliases As List(Of String) = New List(Of String) - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain ResetDomain(domain) domain.AccountName = domainName @@ -498,7 +516,7 @@ Public Class MailEnable Public Overridable Sub AddDomainAlias(ByVal domainName As String, ByVal aliasName As String) Implements IMailServer.AddDomainAlias ' add new domain - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain domain.AccountName = domainName domain.DomainName = aliasName domain.DomainRedirectionHosts = "" @@ -513,7 +531,7 @@ Public Class MailEnable ' get current "main domain" address mappings Dim srcAddr As String = "@" + domainName + "]" Dim maps As ArrayList = New ArrayList - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap ResetAddressMap(map) map.Account = domainName @@ -545,21 +563,21 @@ Public Class MailEnable 'delete all address mappings Dim addr As String = "@" + aliasName.ToLower() + "]" Dim maps As ArrayList = New ArrayList - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap ResetAddressMap(map) map.Account = domainName map.SourceAddress = "[SMTP:*@" + aliasName + "]" - map.RemoveAddressMap() + map.RemoveAddressMap(True) 'delete all the blacklists - Dim blacklist As Object = CreateObject(BLACKLIST_PROG_ID) + Dim blacklist As New WebsitePanel.Providers.Mail.MailEnableDomainBlacklist ResetBlacklist(blacklist) blacklist.Account = domainName blacklist.TargetDomainName = aliasName blacklist.RemoveBlacklist() 'delete all domains - Dim domain As Object = CreateObject(DOMAIN_PROG_ID) + Dim domain As New WebsitePanel.Providers.Mail.MailEnableDomain ResetDomain(domain) domain.AccountName = domainName domain.DomainName = aliasName @@ -568,11 +586,15 @@ Public Class MailEnable #End Region #Region "Accounts" + Public Overridable Function GetAccounts(ByVal domainName As String) As MailAccount() Implements IMailServer.GetAccounts + Dim mailboxes As List(Of MailAccount) = New List(Of MailAccount) - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox + ResetMailbox(mailbox) mailbox.Postoffice = domainName + mailbox.Size = -4 'we use -4 since this prevents the function from calculating quotas, which is slow If mailbox.FindFirstMailbox() = 1 Then Do @@ -583,6 +605,7 @@ Public Class MailEnable End If ResetMailbox(mailbox) mailbox.Postoffice = domainName + mailbox.Size = -4 Loop While mailbox.FindNextMailbox() = 1 End If @@ -591,10 +614,10 @@ Public Class MailEnable Public Overridable Function GetAccount(ByVal mailboxName As String) As MailAccount Implements IMailServer.GetAccount Dim info As MailAccount = Nothing - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox ResetMailbox(mailbox) mailbox.Postoffice = GetDomainName(mailboxName) - mailbox.Mailbox = GetMailboxName(mailboxName) + mailbox.MailboxName = GetMailboxName(mailboxName) If (mailbox.GetMailbox() <> 1) Then Throw New Exception("Could not find the mailbox") @@ -607,10 +630,10 @@ Public Class MailEnable Return info End Function - Private Function GetMailboxInfo(ByVal mailbox As Object) As MailAccount + Private Function GetMailboxInfo(ByVal mailbox As WebsitePanel.Providers.Mail.MailEnableMailbox) As MailAccount Dim info As MailAccount = New MailAccount info.MaxMailboxSize = IIf(mailbox.Limit = -1, 0, mailbox.Limit / 1024) - info.Name = mailbox.Mailbox + "@" + mailbox.Postoffice + info.Name = mailbox.MailboxName + "@" + mailbox.Postoffice Dim redirectAddrs As ArrayList = New ArrayList Dim smtpAddress As String @@ -633,12 +656,12 @@ Public Class MailEnable info.ResponderMessage = mailbox.GetAutoResponderContents() info.ReplyTo = GetMailBoxReplyToAddress(info.Name) - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap map.Account = info.Name map.DestinationAddress = String.Format("[SF:{0}/{1}]", info.Name, info.Name) map.SourceAddress = "" - Dim login As Object = CreateObject(LOGIN_PROG_ID) + Dim login As New WebsitePanel.Providers.Mail.MailEnableLogin ResetLogin(login) login.Account = mailbox.Postoffice login.UserName = info.Name @@ -651,9 +674,9 @@ Public Class MailEnable Return info End Function - Private Function GetMailAliasInfo(ByVal mailbox As Object) As MailAlias + Private Function GetMailAliasInfo(ByVal mailbox As WebsitePanel.Providers.Mail.MailEnableMailbox) As MailAlias Dim info As MailAlias = New MailAlias - info.Name = mailbox.Mailbox + "@" + mailbox.Postoffice + info.Name = mailbox.MailboxName + "@" + mailbox.Postoffice Dim redirectAddrs As ArrayList = New ArrayList Dim smtpAddress As String @@ -673,12 +696,12 @@ Public Class MailEnable info.DeleteOnForward = (mailbox.RedirectStatus.Equals(1)) info.Enabled = (mailbox.Status = 1) - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap map.Account = info.Name map.DestinationAddress = String.Format("[SF:{0}/{1}]", info.Name, info.Name) map.SourceAddress = "" - Dim login As Object = CreateObject(LOGIN_PROG_ID) + Dim login As New WebsitePanel.Providers.Mail.MailEnableLogin ResetLogin(login) login.Account = mailbox.Postoffice login.UserName = info.Name @@ -692,22 +715,22 @@ Public Class MailEnable End Function Public Overridable Function AccountExists(ByVal mailboxName As String) As Boolean Implements IMailServer.AccountExists - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox ResetMailbox(mailbox) mailbox.Postoffice = GetDomainName(mailboxName) - mailbox.Mailbox = GetMailboxName(mailboxName) + mailbox.MailboxName = GetMailboxName(mailboxName) Return (mailbox.GetMailbox() = 1) End Function Public Overridable Sub CreateAccount(ByVal info As MailAccount) Implements IMailServer.CreateAccount - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox Dim domainName As String = GetDomainName(info.Name) Dim mailboxName As String = GetMailboxName(info.Name) mailbox.Postoffice = domainName mailbox.Limit = IIf(info.MaxMailboxSize = 0, -1, info.MaxMailboxSize * 1024) ' convert to kilobytes - mailbox.Mailbox = GetMailboxName(info.Name) + mailbox.MailboxName = GetMailboxName(info.Name) If info.ForwardingAddresses Is Nothing Then info.ForwardingAddresses = New String() {} @@ -749,7 +772,7 @@ Public Class MailEnable CreateAddressMapsForAllDomains(domainName, mailboxName, destinationAddress) ' create login - Dim login As Object = CreateObject(LOGIN_PROG_ID) + Dim login As New WebsitePanel.Providers.Mail.MailEnableLogin login.Account = domainName login.Password = info.Password login.Status = IIf(info.Enabled, 1, 0) @@ -770,9 +793,9 @@ Public Class MailEnable Dim domainName As String = GetDomainName(info.Name) Dim mailboxName As String = GetMailboxName(info.Name) - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox mailbox.Postoffice = domainName - mailbox.Mailbox = mailboxName + mailbox.MailboxName = mailboxName If info.ForwardingAddresses Is Nothing Then info.ForwardingAddresses = New String() {} @@ -811,6 +834,8 @@ Public Class MailEnable If (String.IsNullOrEmpty(info.ReplyTo) = False) Then SetMailBoxReplyToAddress(info.Name, info.ReplyTo) + Else + SetMailBoxReplyToAddress(info.Name, "") End If mailbox.SetAutoResponderStatus(info.ResponderEnabled) @@ -824,7 +849,7 @@ Public Class MailEnable ' change login password If (info.Password.Length > 0) Then - Dim login As Object = CreateObject(LOGIN_PROG_ID) + Dim login As New WebsitePanel.Providers.Mail.MailEnableLogin ResetLogin(login) login.Account = domainName login.UserName = info.Name @@ -843,23 +868,25 @@ Public Class MailEnable ' build autoresponder file WriteMailboxAutoresponderFile(info) + + End Sub Public Overridable Sub DeleteAccount(ByVal name As String) Implements IMailServer.DeleteAccount Dim domainName As String = GetDomainName(name) Dim mailboxName As String = GetMailboxName(name) - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox ResetMailbox(mailbox) mailbox.Postoffice = domainName - mailbox.Mailbox = mailboxName + mailbox.MailboxName = mailboxName If (mailbox.RemoveMailbox() <> 1) Then Throw New Exception(String.Format("Could not delete mailbox '{0}'", mailboxName)) End If 'delete the login for this mailbox - Dim login As Object = CreateObject(LOGIN_PROG_ID) + Dim login As New WebsitePanel.Providers.Mail.MailEnableLogin ResetLogin(login) login.Account = domainName login.UserName = name @@ -870,7 +897,7 @@ Public Class MailEnable 'delete the address map for this mailbox - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap ResetAddressMap(map) map.Account = domainName map.DestinationAddress = String.Format("[SF:{0}/{1}]", domainName, mailboxName) @@ -885,10 +912,13 @@ Public Class MailEnable End Function Public Function GetMailAliases(ByVal domainName As String) As MailAlias() Implements IMailServer.GetMailAliases + Dim mailAliases As List(Of MailAlias) = New List(Of MailAlias) - Dim mailbox As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailbox As New WebsitePanel.Providers.Mail.MailEnableMailbox + ResetMailbox(mailbox) mailbox.Postoffice = domainName + mailbox.Size = -4 If mailbox.FindFirstMailbox() = 1 Then Do @@ -898,18 +928,20 @@ Public Class MailEnable End If ResetMailbox(mailbox) mailbox.Postoffice = domainName + mailbox.Size = -4 Loop While mailbox.FindNextMailbox() = 1 End If Return mailAliases.ToArray() End Function + Public Function GetMailAlias(ByVal mailAliasName As String) As MailAlias Implements IMailServer.GetMailAlias Dim info As MailAlias = Nothing - Dim mailAlias As Object = CreateObject(MAILBOX_PROG_ID) + Dim mailAlias As New WebsitePanel.Providers.Mail.MailEnableMailbox ResetMailbox(mailAlias) mailAlias.Postoffice = GetDomainName(mailAliasName) - mailAlias.Mailbox = GetMailboxName(mailAliasName) + mailAlias.MailboxName = GetMailboxName(mailAliasName) If (mailAlias.GetMailbox() <> 1) Then Throw New Exception("Could not find the mailbox") @@ -942,7 +974,7 @@ Public Class MailEnable ' ============================ Public Overridable Function GroupExists(ByVal groupName As String) As Boolean Implements IMailServer.GroupExists - Dim group As Object = CreateObject(GROUP_PROG_ID) + Dim group As New WebsitePanel.Providers.Mail.MailEnableGroup ResetGroup(group) group.Postoffice = GetDomainName(groupName) group.GroupName = GetMailboxName(groupName) @@ -951,7 +983,7 @@ Public Class MailEnable End Function Public Overridable Function GetGroup(ByVal groupName As String) As MailGroup Implements IMailServer.GetGroup - Dim objGroup As Object = CreateObject(GROUP_PROG_ID) + Dim objGroup As New WebsitePanel.Providers.Mail.MailEnableGroup ResetGroup(objGroup) objGroup.Postoffice = GetDomainName(groupName) objGroup.GroupName = GetMailboxName(groupName) @@ -966,7 +998,7 @@ Public Class MailEnable Public Overridable Function GetGroups(ByVal domainName As String) As MailGroup() Implements IMailServer.GetGroups Dim groups As List(Of MailGroup) = New List(Of MailGroup) - Dim objGroup As Object = CreateObject(GROUP_PROG_ID) + Dim objGroup As New WebsitePanel.Providers.Mail.MailEnableGroup ResetGroup(objGroup) objGroup.Postoffice = domainName @@ -992,7 +1024,7 @@ Public Class MailEnable group.Members = New String() {} End If - Dim objGroup As Object = CreateObject(GROUP_PROG_ID) + Dim objGroup As New WebsitePanel.Providers.Mail.MailEnableGroup ResetGroup(objGroup) objGroup.Postoffice = domainName @@ -1007,7 +1039,7 @@ Public Class MailEnable ' add group members Dim member As String For Each member In group.Members - Dim groupMember As Object = CreateObject(GROUP_MEMBER_PROG_ID) + Dim groupMember As New WebsitePanel.Providers.Mail.MailEnableGroupMember groupMember.Postoffice = domainName groupMember.Address = String.Format("[SMTP:{0}]", member) groupMember.Mailbox = groupName @@ -1028,7 +1060,7 @@ Public Class MailEnable group.Members = New String() {} End If - Dim objGroup As Object = CreateObject(GROUP_PROG_ID) + Dim objGroup As New WebsitePanel.Providers.Mail.MailEnableGroup ResetGroup(objGroup) objGroup.Postoffice = domainName @@ -1046,7 +1078,7 @@ Public Class MailEnable IIf(group.Enabled, 1, 0)) 'delete group members - Dim objMember As Object = CreateObject(GROUP_MEMBER_PROG_ID) + Dim objMember As New WebsitePanel.Providers.Mail.MailEnableGroupMember objMember.Postoffice = domainName objMember.Mailbox = groupName objMember.Address = "" @@ -1055,7 +1087,7 @@ Public Class MailEnable ' add group members Dim member As String For Each member In group.Members - Dim groupMember As Object = CreateObject(GROUP_MEMBER_PROG_ID) + Dim groupMember As New WebsitePanel.Providers.Mail.MailEnableGroupMember groupMember.Postoffice = domainName groupMember.Address = String.Format("[SMTP:{0}]", member) groupMember.Mailbox = groupName @@ -1071,21 +1103,21 @@ Public Class MailEnable Dim groupName As String = GetMailboxName(name) ' remove group - Dim objGroup As Object = CreateObject(GROUP_PROG_ID) + Dim objGroup As New WebsitePanel.Providers.Mail.MailEnableGroup ResetGroup(objGroup) objGroup.Postoffice = domainName objGroup.GroupName = groupName objGroup.RemoveGroup() 'delete group members - Dim objMember As Object = CreateObject(GROUP_MEMBER_PROG_ID) + Dim objMember As New WebsitePanel.Providers.Mail.MailEnableGroupMember objMember.Postoffice = domainName objMember.Mailbox = groupName objMember.Address = "" objMember.RemoveGroupMember() ' delete address maps - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap ResetAddressMap(map) map.Account = domainName map.DestinationAddress = String.Format("[SF:{0}/{1}]", domainName, groupName) @@ -1096,7 +1128,7 @@ Public Class MailEnable #Region "Lists" Public Overridable Function GetList(ByVal maillistName As String) As MailList Implements IMailServer.GetList - Dim mailList As Object = CreateObject(MAILLIST_PROG_ID) + Dim mailList As New WebsitePanel.Providers.Mail.MailEnableList ResetMaillist(mailList) mailList.AccountName = GetDomainName(maillistName) mailList.ListName = GetMailboxName(maillistName) @@ -1112,7 +1144,7 @@ Public Class MailEnable Dim maillists As List(Of MailList) = New List(Of MailList) Try - Dim mailList As Object = CreateObject(MAILLIST_PROG_ID) + Dim mailList As New WebsitePanel.Providers.Mail.MailEnableList ResetMaillist(mailList) mailList.AccountName = domainName @@ -1165,7 +1197,7 @@ Public Class MailEnable Dim domainName As String = GetDomainName(name) Dim mailListName As String = GetMailboxName(name) - Dim listMember As Object = CreateObject(LIST_MEMBER_PROG_ID) + Dim listMember As New WebsitePanel.Providers.Mail.MailEnableListMember listMember.AccountName = domainName listMember.ListName = mailListName listMember.Address = "" @@ -1192,7 +1224,7 @@ Public Class MailEnable End Function Public Overridable Function ListExists(ByVal maillistName As String) As Boolean Implements IMailServer.ListExists - Dim mailList As Object = CreateObject(MAILLIST_PROG_ID) + Dim mailList As New WebsitePanel.Providers.Mail.MailEnableList ResetMaillist(mailList) mailList.AccountName = GetDomainName(maillistName) mailList.ListName = GetMailboxName(maillistName) @@ -1210,7 +1242,7 @@ Public Class MailEnable info.Members = New String() {} End If - Dim mailList As Object = CreateObject(MAILLIST_PROG_ID) + Dim mailList As New WebsitePanel.Providers.Mail.MailEnableList ResetMaillist(mailList) mailList.AccountName = domainName @@ -1239,7 +1271,7 @@ Public Class MailEnable 'create mail list members Dim member As String For Each member In info.Members - Dim listMember As Object = CreateObject(LIST_MEMBER_PROG_ID) + Dim listMember As New WebsitePanel.Providers.Mail.MailEnableListMember listMember.AccountName = domainName listMember.Address = String.Format("[SMTP:{0}]", member) listMember.ListMemberType = 0 @@ -1265,7 +1297,7 @@ Public Class MailEnable info.Members = New String() {} End If - Dim mailList As Object = CreateObject(MAILLIST_PROG_ID) + Dim mailList As New WebsitePanel.Providers.Mail.MailEnableList ResetMaillist(mailList) mailList.AccountName = domainName @@ -1318,7 +1350,7 @@ Public Class MailEnable -1) 'delete list members - Dim listMember As Object = CreateObject(LIST_MEMBER_PROG_ID) + Dim listMember As New WebsitePanel.Providers.Mail.MailEnableListMember listMember.AccountName = domainName listMember.ListName = maillistName listMember.Address = "" @@ -1329,7 +1361,7 @@ Public Class MailEnable 'create mail list members Dim member As String For Each member In info.Members - listMember = CreateObject(LIST_MEMBER_PROG_ID) + listMember = New WebsitePanel.Providers.Mail.MailEnableListMember listMember.AccountName = domainName listMember.ListName = maillistName listMember.Address = String.Format("[SMTP:{0}]", member) @@ -1353,14 +1385,14 @@ Public Class MailEnable Dim maillistName As String = GetMailboxName(name) ' remove mailing list - Dim mailList As Object = CreateObject(MAILLIST_PROG_ID) + Dim mailList As New WebsitePanel.Providers.Mail.MailEnableList ResetMaillist(mailList) mailList.ListName = maillistName mailList.AccountName = domainName mailList.RemoveList() ' delete list members - Dim listMember As Object = CreateObject(LIST_MEMBER_PROG_ID) + Dim listMember As New WebsitePanel.Providers.Mail.MailEnableListMember listMember.AccountName = domainName listMember.ListName = maillistName listMember.Address = "" @@ -1370,7 +1402,7 @@ Public Class MailEnable listMember.RemoveListMember() ' delete address maps - Dim map As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim map As New WebsitePanel.Providers.Mail.MailEnableAddressMap ResetAddressMap(map) map.Account = domainName map.DestinationAddress = String.Format("[LS:{0}/{1}]", domainName, maillistName) @@ -1415,10 +1447,10 @@ Public Class MailEnable login.Status = -1 End Sub - Private Sub ResetMailbox(ByVal mailbox As Object) + Private Sub ResetMailbox(ByVal mailbox As WebsitePanel.Providers.Mail.MailEnableMailbox) mailbox.Postoffice = "" mailbox.Host = "" - mailbox.Mailbox = "" + mailbox.MailboxName = "" mailbox.RedirectAddress = "" mailbox.Limit = -1 mailbox.RedirectStatus = -1 @@ -1495,7 +1527,7 @@ Public Class MailEnable Dim domainName As String = GetDomainName(name) Dim groupName As String = GetMailboxName(name) - Dim groupMember As Object = CreateObject(GROUP_MEMBER_PROG_ID) + Dim groupMember As New WebsitePanel.Providers.Mail.MailEnableGroupMember groupMember.Postoffice = domainName groupMember.Mailbox = groupName groupMember.Address = "" @@ -1516,8 +1548,8 @@ Public Class MailEnable End Function Private Sub CreateAddressMapsForAllDomains(ByVal domainName As String, ByVal aliasName As String, ByVal targetAddress As String) - Dim oDomain As Object = CreateObject(DOMAIN_PROG_ID) - Dim oAddressMap As Object = CreateObject(ADDRESS_MAP_PROG_ID) + Dim oDomain As New WebsitePanel.Providers.Mail.MailEnableDomain + Dim oAddressMap As New WebsitePanel.Providers.Mail.MailEnableAddressMap oDomain.AccountName = domainName oDomain.DomainName = "" oDomain.Status = -1 @@ -1586,88 +1618,88 @@ Public Class MailEnable End Sub Public Overrides Sub DeleteServiceItems(ByVal items() As ServiceProviderItem) - For Each item As ServiceProviderItem In items - If TypeOf item Is MailDomain Then - Try - DeleteDomain(item.Name) - Catch ex As Exception - Log.WriteError(String.Format("Error deleting '{0}' mail domain", item.Name), ex) - End Try - End If - Next - End Sub + For Each item As ServiceProviderItem In items + If TypeOf item Is MailDomain Then + Try + DeleteDomain(item.Name) + Catch ex As Exception + Log.WriteError(String.Format("Error deleting '{0}' mail domain", item.Name), ex) + End Try + End If + Next + End Sub Public Overrides Function GetServiceItemsDiskSpace(ByVal items() As ServiceProviderItem) As ServiceProviderItemDiskSpace() - Dim itemsDiskspace As List(Of ServiceProviderItemDiskSpace) = New List(Of ServiceProviderItemDiskSpace) + Dim itemsDiskspace As List(Of ServiceProviderItemDiskSpace) = New List(Of ServiceProviderItemDiskSpace) - ' update items with diskspace - Dim item As ServiceProviderItem - For Each item In items - If TypeOf item Is MailAccount Then - Try - ' get mailbox size - Dim name As String = item.Name + ' update items with diskspace + Dim item As ServiceProviderItem + For Each item In items + If TypeOf item Is MailAccount Then + Try + ' get mailbox size + Dim name As String = item.Name - ' try to get MailEnable postoffices path - Dim poPath As String = GetPostofficesPath() - If poPath Is Nothing Then - Continue For - End If - Dim mailboxName As String = name.Substring(0, name.IndexOf("@")) - Dim domainName As String = name.Substring((name.IndexOf("@") + 1)) + ' try to get MailEnable postoffices path + Dim poPath As String = GetPostofficesPath() + If poPath Is Nothing Then + Continue For + End If + Dim mailboxName As String = name.Substring(0, name.IndexOf("@")) + Dim domainName As String = name.Substring((name.IndexOf("@") + 1)) - Dim mailboxPath As String = [String].Format("{0}\{1}\Mailroot\{2}", poPath, domainName, mailboxName) + Dim mailboxPath As String = [String].Format("{0}\{1}\Mailroot\{2}", poPath, domainName, mailboxName) - ' calculate disk space - Dim diskspace As New ServiceProviderItemDiskSpace() - diskspace.ItemId = item.Id - diskspace.DiskSpace = FileUtils.CalculateFolderSize(mailboxPath) - itemsDiskspace.Add(diskspace) - Catch ex As Exception - Log.WriteError("Error calculating disk space for mail account: " + item.Name, ex) - End Try - End If - Next item + ' calculate disk space + Dim diskspace As New ServiceProviderItemDiskSpace() + diskspace.ItemId = item.Id + diskspace.DiskSpace = FileUtils.CalculateFolderSize(mailboxPath) + itemsDiskspace.Add(diskspace) + Catch ex As Exception + Log.WriteError("Error calculating disk space for mail account: " + item.Name, ex) + End Try + End If + Next item - Return itemsDiskspace.ToArray() + Return itemsDiskspace.ToArray() End Function Public Overrides Function GetServiceItemsBandwidth(ByVal items() As ServiceProviderItem, ByVal since As Date) As ServiceProviderItemBandwidth() - Dim itemsBandwidth(items.Length) As ServiceProviderItemBandwidth + Dim itemsBandwidth(items.Length) As ServiceProviderItemBandwidth - Dim logsPath As String = GetLoggingPath() - If logsPath Is Nothing Then - Return Nothing - End If - ' calculate bandwidth for mail enable - ' parse mail logs - Dim parser As New LogParser("Mail", "mailenable_pop", Path.Combine(logsPath, "pop"), "account") + Dim logsPath As String = GetLoggingPath() + If logsPath Is Nothing Then + Return Nothing + End If + ' calculate bandwidth for mail enable + ' parse mail logs + Dim parser As New LogParser("Mail", "mailenable_pop", Path.Combine(logsPath, "pop"), "account") parser.ParseLogs(Of LogReader)() - parser = New LogParser("Mail", "mailenable_smtp", Path.Combine(logsPath, "smtp"), "account") + parser = New LogParser("Mail", "mailenable_smtp", Path.Combine(logsPath, "smtp"), "account") parser.ParseLogs(Of MELogReader)() - ' update items with diskspace - Dim i As Integer - For i = 0 To items.Length - 1 - Dim item As ServiceProviderItem = items(i) + ' update items with diskspace + Dim i As Integer + For i = 0 To items.Length - 1 + Dim item As ServiceProviderItem = items(i) - ' create new bandwidth object - itemsBandwidth(i) = New ServiceProviderItemBandwidth() - itemsBandwidth(i).ItemId = item.Id - itemsBandwidth(i).Days = New DailyStatistics(0) {} + ' create new bandwidth object + itemsBandwidth(i) = New ServiceProviderItemBandwidth() + itemsBandwidth(i).ItemId = item.Id + itemsBandwidth(i).Days = New DailyStatistics(0) {} - If TypeOf item Is MailDomain Then - Try - ' get daily statistics - itemsBandwidth(i).Days = parser.GetDailyStatistics(since, New String() {item.Name}) - Catch ex As Exception - Log.WriteError("Error calculating bandwidth for mail domain: " + item.Name, ex) - End Try - End If - Next i - Return itemsBandwidth + If TypeOf item Is MailDomain Then + Try + ' get daily statistics + itemsBandwidth(i).Days = parser.GetDailyStatistics(since, New String() {item.Name}) + Catch ex As Exception + Log.WriteError("Error calculating bandwidth for mail domain: " + item.Name, ex) + End Try + End If + Next i + Return itemsBandwidth End Function Private Sub DeleteMailBoxDirectory(ByVal name As String) @@ -1772,87 +1804,60 @@ Public Class MailEnable End Sub Private Sub SetMailBoxReplyToAddress(ByVal mailbox As String, ByVal replyToAddress As String) - Dim mailBoxFile As String = String.Format("Config\PostOffices\{0}\MAILBOXES\{1}.sys", GetDomainName(mailbox), GetMailboxName(mailbox)) - Dim mailboxPath As String = Path.Combine(GetInstallPath(), mailBoxFile) - If (File.Exists(mailboxPath) <> True) Then - Dim stream As New IO.FileStream(mailboxPath, IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite, IO.FileShare.None) - Dim writer As New StreamWriter(stream) - writer.WriteLine("[General]") - writer.Dispose() - stream.Dispose() - End If + Dim oMEAOSO As New WebsitePanel.Providers.Mail.MailEnableOption - Dim reader As New StreamReader(mailboxPath) + With oMEAOSO + .Scope = 2 + .Query = GetDomainName(mailbox) & "/" & GetMailboxName(mailbox) + .ValueName = "ReplyAddress" + .Value = replyToAddress + .SetOption() + End With - Dim Count As Integer = 0 - While reader.Peek <> -1 - Dim line As String = reader.ReadLine() - If line.Contains("ReplyAddress") Then - reader.Dispose() - ReplaceLine(mailboxPath, Count, String.Format("ReplyAddress={0}", replyToAddress)) - Exit Sub - End If - Count = Count + 1 - End While - - reader.Dispose() - AppendLine(mailboxPath, String.Format("ReplyAddress={0}", replyToAddress)) - - 'Dim writer As New StreamWriter(mailboxPath) - 'writer.WriteLine(String.Format("ReplyAddress={0}", replyToAddress)) - 'writer.Close() - 'writer.Dispose() - - End Sub - - - Private Sub ReplaceLine(ByRef FileAddress As String, ByRef line As Integer, ByVal address As String) - Dim TheFileLines As New List(Of String) - TheFileLines.AddRange(System.IO.File.ReadAllLines(FileAddress)) - If line >= TheFileLines.Count Then Exit Sub - TheFileLines.RemoveAt(line) - TheFileLines.Add(address) - File.WriteAllLines(FileAddress, TheFileLines.ToArray) - End Sub - - Private Sub AppendLine(ByRef FileAddress As String, ByRef line As String) - Dim TheFileLines As New List(Of String) - TheFileLines.AddRange(System.IO.File.ReadAllLines(FileAddress)) - TheFileLines.Add(line) - File.WriteAllLines(FileAddress, TheFileLines.ToArray) End Sub Private Function GetMailBoxReplyToAddress(ByVal mailbox As String) - Dim mailBoxFile As String = String.Format("Config\PostOffices\{0}\MAILBOXES\{1}.sys", GetDomainName(mailbox), GetMailboxName(mailbox)) - Dim mailboxPath As String = Path.Combine(GetInstallPath(), mailBoxFile) - If (File.Exists(mailboxPath) = False) Then - Return String.Empty - End If + Dim oMEAOSO As New WebsitePanel.Providers.Mail.MailEnableOption - Dim reader As New StreamReader(mailboxPath) + With oMEAOSO + .Scope = 2 + .Query = GetDomainName(mailbox) & "/" & GetMailboxName(mailbox) + .ValueName = "ReplyAddress" + .GetOption() + Return .Value + End With - While reader.Peek <> -1 - Dim line As String = reader.ReadLine() - If line.Contains("ReplyAddress") Then - Dim split As String() = line.Split(New [Char]() {"="c}) - Return split(1) - End If - End While - reader.Dispose() - Return String.Empty End Function - Private Function GetPostofficesPath() As String - Dim key As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") - Return CStr(key.GetValue("Mail Root")) + Function GetMailEnableRegistryItem(item As String) As String + + Dim key As RegistryKey + + If IntPtr.Size > 4 Then + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Mail Enable\Mail Enable") + Else + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") + End If + + Return CStr(key.GetValue(item)) + + End Function + + + Shared Function GetPostofficesPath() As String + + Dim oLocal As New MailEnable + Return oLocal.GetMailEnableRegistryItem("Mail Root") + End Function Private Function GetInstallPath() As String - Dim key As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") - Return CStr(key.GetValue("Program Directory")) + + Return GetMailEnableRegistryItem("Program Directory") + End Function @@ -1953,69 +1958,84 @@ Public Class MailEnable End Function Private Function GetAnnotationPath(ByVal postOfficeName As String) As String + + 'the annotation paths are in the configuration directory + Dim programPath As String = "" - Dim key32bit As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") - If (key32bit Is Nothing) Then - Dim key64bit As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Mail Enable\Mail Enable") - If (key64bit Is Nothing) Then - Return String.Empty - Else - programPath = CStr(key64bit.GetValue("Data Directory")) - Return Path.Combine(programPath, String.Format("Config\Postoffices\{0}\ANNOTATIONS", postOfficeName)) - End If + Dim key As RegistryKey + + If IntPtr.Size > 4 Then + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Mail Enable\Mail Enable") Else - programPath = CStr(key32bit.GetValue("Data Directory")) - Return Path.Combine(programPath, String.Format("Config\Postoffices\{0}\ANNOTATIONS", postOfficeName)) + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") End If + If (key Is Nothing) Then + Return String.Empty + Else + programPath = CStr(key.GetValue("Configuration Directory")) + Return Path.Combine(programPath, String.Format("Postoffices\{0}\ANNOTATIONS", postOfficeName)) + End If + + End Function + + Private Function NonCString(ByVal InString As String) As String + Dim NTPos As Integer + NTPos = InStr(1, InString, Chr(0), CompareMethod.Binary) + If NTPos > 0 Then + NonCString = Left(InString, NTPos - 1) + Else + NonCString = InString + End If + End Function + + Private Function CString(ByVal InString As String) As String + CString = InString & Chr(0) End Function Private Function GetLoggingPath() As String Dim programPath As String = "" - Dim key32bit As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") - If (key32bit Is Nothing) Then - Dim key64bit As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Mail Enable\Mail Enable") - If (key64bit Is Nothing) Then - Return String.Empty - Else - Return CStr(key64bit.GetValue("W3C Logging Directory")) - End If + Dim key As RegistryKey + + If IntPtr.Size > 4 Then + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Mail Enable\Mail Enable") Else - Return CStr(key32bit.GetValue("W3C Logging Directory")) + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") + End If + + If (key Is Nothing) Then + Return String.Empty + Else + Return CStr(key.GetValue("W3C Logging Directory")) End If End Function + #End Region Public Overrides Function IsInstalled() As Boolean + Dim version As String = "" - Dim key32bit As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") - If (key32bit Is Nothing) Then - Dim key64bit As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Mail Enable\Mail Enable") - If (key64bit Is Nothing) Then - Return False - Else - version = CStr(key64bit.GetValue("Enterprise Version")) - If (version Is Nothing) Then - version = CStr(key64bit.GetValue("Version")) - If (version Is Nothing Or version.Equals("0")) Then - version = CStr(key64bit.GetValue("Professional Version")) - End If - End If - End If + Dim key As RegistryKey + + If IntPtr.Size > 4 Then + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Mail Enable\Mail Enable") Else - version = CStr(key32bit.GetValue("Enterprise Version")) - If (version Is Nothing) Then - version = CStr(key32bit.GetValue("Version")) - If (version Is Nothing Or version.Equals("0")) Then - version = CStr(key32bit.GetValue("Professional Version")) - End If + key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Mail Enable\Mail Enable") + End If + + version = CStr(key.GetValue("Enterprise Version")) + If (version Is Nothing) Then + version = CStr(key.GetValue("Version")) + If (version Is Nothing Or version.Equals("0")) Then + version = CStr(key.GetValue("Professional Version")) End If End If + If [String].IsNullOrEmpty(version) = False Then Dim split As String() = version.Split(New [Char]() {"."c}) - Return split(0).Equals("1") Or split(0).Equals("2") Or split(0).Equals("3") Or split(0).Equals("4") + Return split(0).Equals("1") Or split(0).Equals("2") Or split(0).Equals("3") Or split(0).Equals("4") Or split(0).Equals("5") Or split(0).Equals("6") Else Return False End If diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableAddressMap.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableAddressMap.vb new file mode 100644 index 00000000..30f8db75 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableAddressMap.vb @@ -0,0 +1,261 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Option Strict Off +Option Explicit On + +Namespace WebsitePanel.Providers.Mail + Public Class MailEnableAddressMap + Inherits MarshalByRefObject + + Private AccountVal As String = "" + Private SourceAddressVal As String = "" + Private DestinationAddressVal As String = "" + Private ScopeVal As String = "" + Private HostVal As String = "" + Private StatusVal As Integer + + Private Structure IADDRESSMAPENTRYTYPE + Public Account As String + Public SourceAddress As String + Public DestinationAddress As String + Public Scope As String + Public Status As Integer + End Structure + + Private Declare Function AddressMapGet Lib "MEAIAM.DLL" (ByRef lpAddressMap As IADDRESSMAPENTRYTYPE) As Integer + Private Declare Function AddressMapFindFirst Lib "MEAIAM.DLL" (ByRef lpAddressMap As IADDRESSMAPENTRYTYPE) As Integer + Private Declare Function AddressMapFindNext Lib "MEAIAM.DLL" (ByRef lpAddressMap As IADDRESSMAPENTRYTYPE) As Integer + Private Declare Function AddressMapAdd Lib "MEAIAM.DLL" (ByRef lpAddressMap As IADDRESSMAPENTRYTYPE) As Integer + Private Declare Function AddressMapEdit Lib "MEAIAM.DLL" (ByRef TargetAddressMap As IADDRESSMAPENTRYTYPE, ByRef NewAddressMap As IADDRESSMAPENTRYTYPE) As Integer + Private Declare Function AddressMapRemove Lib "MEAIAM.DLL" (ByRef lpAddressMap As IADDRESSMAPENTRYTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAIAM.DLL" (ByVal CurrentHost As String) As Integer + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Public Function GetAddressMap() As Integer + + Dim CAddressMap As IADDRESSMAPENTRYTYPE + + CAddressMap.Account = Account + CAddressMap.SourceAddress = SourceAddress + CAddressMap.DestinationAddress = DestinationAddress + CAddressMap.Scope = Scope + CAddressMap.Status = Status + GetAddressMap = AddressMapGet(CAddressMap) + Account = CAddressMap.Account + SourceAddress = CAddressMap.SourceAddress + DestinationAddress = CAddressMap.DestinationAddress + Scope = CAddressMap.Scope + Status = CAddressMap.Status + End Function + + Public Function FindFirstAddressMap() As Integer + Dim CAddressMap As IADDRESSMAPENTRYTYPE + CAddressMap.Account = Account + CAddressMap.SourceAddress = SourceAddress + CAddressMap.DestinationAddress = DestinationAddress + CAddressMap.Scope = Scope + CAddressMap.Status = Status + FindFirstAddressMap = AddressMapFindFirst(CAddressMap) + Account = CAddressMap.Account + SourceAddress = CAddressMap.SourceAddress + DestinationAddress = CAddressMap.DestinationAddress + Scope = CAddressMap.Scope + Status = CAddressMap.Status + End Function + + Public Function FindNextAddressMap() As Integer + Dim CAddressMap As IADDRESSMAPENTRYTYPE + CAddressMap.Account = Account + CAddressMap.SourceAddress = SourceAddress + CAddressMap.DestinationAddress = DestinationAddress + CAddressMap.Scope = Scope + CAddressMap.Status = Status + FindNextAddressMap = AddressMapFindNext(CAddressMap) + Account = CAddressMap.Account + SourceAddress = CAddressMap.SourceAddress + DestinationAddress = CAddressMap.DestinationAddress + Scope = CAddressMap.Scope + Status = CAddressMap.Status + End Function + + Public Function AddAddressMap() As Integer + Dim CAddressMap As IADDRESSMAPENTRYTYPE + CAddressMap.Account = Account + CAddressMap.SourceAddress = SourceAddress + CAddressMap.DestinationAddress = DestinationAddress + CAddressMap.Scope = Scope + CAddressMap.Status = Status + AddAddressMap = AddressMapAdd(CAddressMap) + Account = CAddressMap.Account + SourceAddress = CAddressMap.SourceAddress + DestinationAddress = CAddressMap.DestinationAddress + Scope = CAddressMap.Scope + Status = CAddressMap.Status + End Function + + Private Function CString(ByVal InString As String) As String + CString = InString & Chr(0) + End Function + + Private Function NonCString(ByVal InString As String) As String + Dim NTPos As Integer + NTPos = InStr(1, InString, Chr(0), CompareMethod.Binary) + If NTPos > 0 Then + NonCString = Left(InString, NTPos - 1) + Else + NonCString = InString + End If + + End Function + Public Function RemoveAddressMap(Optional ByVal DeleteAll As Boolean = False) As Integer + Dim CAddressMap As IADDRESSMAPENTRYTYPE + Dim lResult As Long + + 'if the one to remove is a catchall we need to rename first + If Not DeleteAll And InStr(1, SourceAddress, "[SMTP:*@", vbTextCompare) = 1 Then + + Dim oAddressMap As New MailEnableAddressMap + + With oAddressMap + .Account = Account + .DestinationAddress = DestinationAddress + .Scope = "" + .SourceAddress = SourceAddress + End With + + lResult = oAddressMap.EditAddressMap(Account, "[SMTP:___~@deleteme]", "[SF:___~" & Account & "/toremove]", "", -1) + + oAddressMap = Nothing + + CAddressMap.Account = CString(Account) + CAddressMap.SourceAddress = CString("[SMTP:___~@deleteme]") + CAddressMap.DestinationAddress = CString("[SF:___~" & Account & "/toremove]") + CAddressMap.Scope = CString("") + CAddressMap.Status = Status + RemoveAddressMap = AddressMapRemove(CAddressMap) + Account = NonCString(CAddressMap.Account) + SourceAddress = NonCString(CAddressMap.SourceAddress) + DestinationAddress = NonCString(CAddressMap.DestinationAddress) + Scope = NonCString(CAddressMap.Scope) + Status = CAddressMap.Status + + Exit Function + End If + + CAddressMap.Account = CString(Account) + CAddressMap.SourceAddress = CString(SourceAddress) + CAddressMap.DestinationAddress = CString(DestinationAddress) + CAddressMap.Scope = CString(Scope) + CAddressMap.Status = Status + RemoveAddressMap = AddressMapRemove(CAddressMap) + Account = NonCString(CAddressMap.Account) + SourceAddress = NonCString(CAddressMap.SourceAddress) + DestinationAddress = NonCString(CAddressMap.DestinationAddress) + Scope = NonCString(CAddressMap.Scope) + Status = CAddressMap.Status + End Function + + Public Function EditAddressMap(ByVal NewAccount As String, ByVal NewSourceAddress As String, ByVal NewDestinationAddress As String, ByVal NewScope As String, ByVal NewStatus As Integer) As Integer + Dim CAddressMap As IADDRESSMAPENTRYTYPE + Dim CAddressMapData As IADDRESSMAPENTRYTYPE + CAddressMap.Account = Account + CAddressMap.SourceAddress = SourceAddress + CAddressMap.DestinationAddress = DestinationAddress + CAddressMap.Scope = Scope + CAddressMap.Status = Status + + CAddressMapData.Account = NewAccount + CAddressMapData.SourceAddress = NewSourceAddress + CAddressMapData.DestinationAddress = NewDestinationAddress + CAddressMapData.Scope = NewScope + CAddressMapData.Status = NewStatus + EditAddressMap = AddressMapEdit(CAddressMap, CAddressMapData) + End Function + + Public Property Account() As String + Get + Return Me.AccountVal + End Get + Set(ByVal Value As String) + Me.AccountVal = Value + End Set + End Property + + Public Property SourceAddress() As String + Get + Return Me.SourceAddressVal + End Get + Set(ByVal Value As String) + Me.SourceAddressVal = Value + End Set + End Property + + Public Property DestinationAddress() As String + Get + Return Me.DestinationAddressVal + End Get + Set(ByVal Value As String) + Me.DestinationAddressVal = Value + End Set + End Property + + Public Property Status() As Integer + Get + Return Me.StatusVal + End Get + Set(ByVal Value As Integer) + Me.StatusVal = Value + End Set + End Property + + + Public Property Scope() As String + Get + Return Me.ScopeVal + End Get + Set(ByVal Value As String) + Me.ScopeVal = Value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal Value As String) + Me.HostVal = Value + End Set + End Property + + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableBlacklist.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableBlacklist.vb new file mode 100644 index 00000000..d2e81bba --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableBlacklist.vb @@ -0,0 +1,227 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Option Strict Off +Option Explicit On + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableDomainBlacklist + Inherits MarshalByRefObject + + Private TargetDomainNameVal As String + Private BannedDomainNameVal As String + Private StatusVal As Integer + Private AccountVal As String + Private HostVal As String + + Private Structure ISMTPBLACKLISTTYPE + Public TargetDomainName As String + Public BannedDomainName As String + Public Status As Integer + Public Account As String + End Structure + + Private Declare Function SMTPBlacklistAdd Lib "MEAISM.DLL" (ByRef SMTPBlacklist As ISMTPBLACKLISTTYPE) As Integer + Private Declare Function SMTPBlacklistGet Lib "MEAISM.DLL" (ByRef SMTPBlacklistCriteria As ISMTPBLACKLISTTYPE) As Integer + Private Declare Function SMTPBlacklistEdit Lib "MEAISM.DLL" (ByRef SMTPBlacklistCriteria As ISMTPBLACKLISTTYPE, ByRef SMTPBlacklistData As ISMTPBLACKLISTTYPE) As Integer + Private Declare Function SMTPBlacklistRemove Lib "MEAISM.DLL" (ByRef SMTPBlacklist As ISMTPBLACKLISTTYPE) As Integer + Private Declare Function SMTPBlacklistFindFirst Lib "MEAISM.DLL" (ByRef SMTPBlacklist As ISMTPBLACKLISTTYPE) As Integer + Private Declare Function SMTPBlacklistFindNext Lib "MEAISM.DLL" (ByRef SMTPBlacklist As ISMTPBLACKLISTTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAISM.DLL" (ByVal CurrentHost As String) As Integer + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Public Function AddBlacklist() As Integer + + Dim CBlacklist As ISMTPBLACKLISTTYPE + + CBlacklist.TargetDomainName = TargetDomainName + CBlacklist.BannedDomainName = BannedDomainName + CBlacklist.Status = Status + CBlacklist.Account = Account + + AddBlacklist = SMTPBlacklistAdd(CBlacklist) + + TargetDomainName = CBlacklist.TargetDomainName + BannedDomainName = CBlacklist.BannedDomainName + Status = CBlacklist.Status + Account = CBlacklist.Account + + End Function + + + Public Function GetBlacklist() As Integer + + Dim CBlacklist As ISMTPBLACKLISTTYPE + + CBlacklist.TargetDomainName = TargetDomainName + CBlacklist.BannedDomainName = BannedDomainName + CBlacklist.Status = Status + CBlacklist.Account = Account + + GetBlacklist = SMTPBlacklistGet(CBlacklist) + + TargetDomainName = CBlacklist.TargetDomainName + BannedDomainName = CBlacklist.BannedDomainName + Status = CBlacklist.Status + Account = CBlacklist.Account + + End Function + + + Public Function EditBlacklist(ByVal NewTargetDomainName As String, ByVal NewBannedDomainName As String, ByVal NewStatus As Integer, ByVal NewAccount As String) As Integer + + Dim CBlacklist As ISMTPBLACKLISTTYPE + Dim CBlacklistData As ISMTPBLACKLISTTYPE + + CBlacklist.TargetDomainName = TargetDomainName + CBlacklist.BannedDomainName = BannedDomainName + CBlacklist.Status = Status + CBlacklist.Account = Account + CBlacklistData.TargetDomainName = NewTargetDomainName + CBlacklistData.BannedDomainName = NewBannedDomainName + CBlacklistData.Status = NewStatus + CBlacklistData.Account = NewAccount + + EditBlacklist = SMTPBlacklistEdit(CBlacklist, CBlacklistData) + + TargetDomainName = CBlacklist.TargetDomainName + BannedDomainName = CBlacklist.BannedDomainName + Status = CBlacklist.Status + Account = CBlacklist.Account + + End Function + + + Public Function RemoveBlacklist() As Integer + + Dim CBlacklist As ISMTPBLACKLISTTYPE + + CBlacklist.TargetDomainName = TargetDomainName + CBlacklist.BannedDomainName = BannedDomainName + CBlacklist.Status = Status + CBlacklist.Account = Account + + RemoveBlacklist = SMTPBlacklistRemove(CBlacklist) + + TargetDomainName = CBlacklist.TargetDomainName + BannedDomainName = CBlacklist.BannedDomainName + Status = CBlacklist.Status + Account = CBlacklist.Account + + End Function + + + Public Function FindFirstBlacklist() As Integer + + Dim CBlacklist As ISMTPBLACKLISTTYPE + + CBlacklist.TargetDomainName = TargetDomainName + CBlacklist.BannedDomainName = BannedDomainName + CBlacklist.Status = Status + CBlacklist.Account = Account + + FindFirstBlacklist = SMTPBlacklistFindFirst(CBlacklist) + + TargetDomainName = CBlacklist.TargetDomainName + BannedDomainName = CBlacklist.BannedDomainName + Status = CBlacklist.Status + Account = CBlacklist.Account + + End Function + + + Public Function FindNextBlacklist() As Integer + + Dim CBlacklist As ISMTPBLACKLISTTYPE + + CBlacklist.TargetDomainName = TargetDomainName + CBlacklist.BannedDomainName = BannedDomainName + CBlacklist.Status = Status + CBlacklist.Account = Account + + FindNextBlacklist = SMTPBlacklistFindNext(CBlacklist) + + TargetDomainName = CBlacklist.TargetDomainName + BannedDomainName = CBlacklist.BannedDomainName + Status = CBlacklist.Status + Account = CBlacklist.Account + + End Function + + Public Property TargetDomainName() As String + Get + Return Me.TargetDomainNameVal + End Get + Set(ByVal Value As String) + Me.TargetDomainNameVal = Value + End Set + End Property + + Public Property BannedDomainName() As String + Get + Return Me.BannedDomainNameVal + End Get + Set(ByVal Value As String) + Me.BannedDomainNameVal = Value + End Set + End Property + + Public Property Status() As Integer + Get + Return Me.StatusVal + End Get + Set(ByVal Value As Integer) + Me.StatusVal = Value + End Set + End Property + + Public Property Account() As String + Get + Return Me.AccountVal + End Get + Set(ByVal Value As String) + Me.AccountVal = Value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal Value As String) + Me.HostVal = Value + End Set + End Property + + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableDomain.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableDomain.vb new file mode 100644 index 00000000..736fa129 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableDomain.vb @@ -0,0 +1,400 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Option Strict Off +Option Explicit On + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableDomain + Inherits MarshalByRefObject + + Private DomainNameVal As String + Private StatusVal As Integer + Private DomainRedirectionStatusVal As Integer + Private DomainRedirectionHostsVal As String + Private AccountNameVal As String + Private HostVal As String + Private RetainModeVal As Integer ' this is used to hold messages waiting for pickup by issued ETRN + Private PollForMessagesVal As Integer ' this indicates that we need to poll a host for messages for this domain + Private UpStreamHostVal As String ' this is the address of the host to poll if we are set to poll a remote host + Private PollIntervalVal As Integer ' this is the frequency in minutes that we need to poll the remote host + Private AliasModeVal As Integer + Private AliasNameVal As String + + Private Structure ISMTPDOMAINTYPE + Public DomainName As String + Public Status As Integer + Public DomainRedirectionStatus As Integer + Public DomainRedirectionHosts As String + Public AccountName As String + Public RetainMode As Integer ' this is used to hold messages waiting for pickup by issued ETRN + Public PollForMessages As Integer ' this indicates that we need to poll a host for messages for this domain + Public UpStreamHost As String ' this is the address of the host to poll if we are set to poll a remote host + Public PollInterval As Integer ' this is the frequency in minutes that we need to poll the remote host + Public AliasMode As Integer + Public AliasName As String + End Structure + + Private Declare Function SMTPDomainAdd Lib "MEAISM.DLL" (ByRef SMTPDomain As ISMTPDOMAINTYPE) As Integer + Private Declare Function SMTPDomainGet Lib "MEAISM.DLL" (ByRef SMTPDomainCriteria As ISMTPDOMAINTYPE) As Integer + Private Declare Function SMTPDomainEdit Lib "MEAISM.DLL" (ByRef SMTPDomainCriteria As ISMTPDOMAINTYPE, ByRef SMTPDomainData As ISMTPDOMAINTYPE) As Integer + Private Declare Function SMTPDomainRemove Lib "MEAISM.DLL" (ByRef SMTPDomain As ISMTPDOMAINTYPE) As Integer + Private Declare Function SMTPDomainFindFirst Lib "MEAISM.DLL" (ByRef SMTPDomain As ISMTPDOMAINTYPE) As Integer + Private Declare Function SMTPDomainFindNext Lib "MEAISM.DLL" (ByRef SMTPDomain As ISMTPDOMAINTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAISM.DLL" (ByVal CurrentHost As String) As Integer + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Public Function AddDomain() As Integer + + Dim CDomain As ISMTPDOMAINTYPE + + CDomain.AliasMode = 0 + CDomain.AliasName = "" + CDomain.PollForMessages = 0 + CDomain.PollInterval = 0 + CDomain.RetainMode = 0 + CDomain.UpStreamHost = "" + + CDomain.AccountName = AccountName + CDomain.DomainName = DomainName + CDomain.DomainRedirectionHosts = DomainRedirectionHosts + CDomain.DomainRedirectionStatus = DomainRedirectionStatus + CDomain.Status = Status + + AddDomain = SMTPDomainAdd(CDomain) + + AccountName = CDomain.AccountName + DomainName = CDomain.DomainName + DomainRedirectionHosts = CDomain.DomainRedirectionHosts + DomainRedirectionStatus = CDomain.DomainRedirectionStatus + Status = CDomain.Status + + 'Console.WriteLine("AddDomain called on server") + + End Function + + + Public Function GetDomain() As Integer + + Dim CDomain As ISMTPDOMAINTYPE + CDomain.AliasMode = -1 + CDomain.AliasName = "" + CDomain.PollForMessages = -1 + CDomain.PollInterval = -1 + CDomain.RetainMode = -1 + CDomain.UpStreamHost = "" + + CDomain.AccountName = AccountName + CDomain.DomainName = DomainName + CDomain.DomainRedirectionHosts = DomainRedirectionHosts + CDomain.DomainRedirectionStatus = DomainRedirectionStatus + CDomain.Status = Status + + GetDomain = SMTPDomainGet(CDomain) + + AccountName = CDomain.AccountName + DomainName = CDomain.DomainName + DomainRedirectionHosts = CDomain.DomainRedirectionHosts + DomainRedirectionStatus = CDomain.DomainRedirectionStatus + Status = CDomain.Status + + End Function + + + Public Function EditDomain(ByVal NewDomainName As String, ByVal NewStatus As Integer, ByVal NewDomainRedirectionStatus As Integer, ByVal NewDomainRedirectionHosts As String, ByVal NewAccountName As String) As Integer + + Dim CDomain As ISMTPDOMAINTYPE + CDomain.AliasMode = -1 + CDomain.AliasName = "" + CDomain.PollForMessages = -1 + CDomain.PollInterval = -1 + CDomain.RetainMode = -1 + CDomain.UpStreamHost = "" + Dim CDomainData As ISMTPDOMAINTYPE + + CDomain.AccountName = AccountName + CDomain.DomainName = DomainName + CDomain.DomainRedirectionHosts = DomainRedirectionHosts + CDomain.DomainRedirectionStatus = DomainRedirectionStatus + CDomain.Status = Status + CDomainData.AccountName = NewAccountName + CDomainData.DomainName = NewDomainName + CDomainData.DomainRedirectionHosts = NewDomainRedirectionHosts + CDomainData.DomainRedirectionStatus = NewDomainRedirectionStatus + CDomainData.Status = NewStatus + + CDomainData.AliasMode = 0 + CDomainData.AliasName = "" + CDomainData.PollForMessages = 0 + CDomainData.PollInterval = 0 + CDomainData.RetainMode = 0 + CDomainData.UpStreamHost = "" + + EditDomain = SMTPDomainEdit(CDomain, CDomainData) + + AccountName = CDomain.AccountName + DomainName = CDomain.DomainName + DomainRedirectionHosts = CDomain.DomainRedirectionHosts + DomainRedirectionStatus = CDomain.DomainRedirectionStatus + Status = CDomain.Status + + End Function + + + Public Function RemoveDomain() As Integer + + Dim CDomain As ISMTPDOMAINTYPE + CDomain.AliasMode = -1 + CDomain.AliasName = "" + CDomain.PollForMessages = -1 + CDomain.PollInterval = -1 + CDomain.RetainMode = -1 + CDomain.UpStreamHost = "" + + CDomain.AccountName = AccountName + CDomain.DomainName = DomainName + CDomain.DomainRedirectionHosts = DomainRedirectionHosts + CDomain.DomainRedirectionStatus = DomainRedirectionStatus + CDomain.Status = Status + + RemoveDomain = SMTPDomainRemove(CDomain) + + AccountName = CDomain.AccountName + DomainName = CDomain.DomainName + DomainRedirectionHosts = CDomain.DomainRedirectionHosts + DomainRedirectionStatus = CDomain.DomainRedirectionStatus + Status = CDomain.Status + + End Function + + + Public Function FindFirstDomain() As Integer + + Dim CDomain As ISMTPDOMAINTYPE + CDomain.AliasMode = -1 + CDomain.AliasName = "" + CDomain.PollForMessages = -1 + CDomain.PollInterval = -1 + CDomain.RetainMode = -1 + CDomain.UpStreamHost = "" + + CDomain.AccountName = AccountName + CDomain.DomainName = DomainName + CDomain.DomainRedirectionHosts = DomainRedirectionHosts + CDomain.DomainRedirectionStatus = DomainRedirectionStatus + CDomain.Status = Status + + FindFirstDomain = SMTPDomainFindFirst(CDomain) + + AccountName = CDomain.AccountName + DomainName = CDomain.DomainName + DomainRedirectionHosts = CDomain.DomainRedirectionHosts + DomainRedirectionStatus = CDomain.DomainRedirectionStatus + Status = CDomain.Status + + End Function + + + Public Function FindNextDomain() As Integer + + Dim CDomain As ISMTPDOMAINTYPE + + CDomain.AccountName = AccountName + CDomain.DomainName = DomainName + CDomain.DomainRedirectionHosts = DomainRedirectionHosts + CDomain.DomainRedirectionStatus = DomainRedirectionStatus + CDomain.Status = Status + + + CDomain.AliasMode = -1 + CDomain.AliasName = "" + CDomain.PollForMessages = -1 + CDomain.PollInterval = -1 + CDomain.RetainMode = -1 + CDomain.UpStreamHost = "" + + FindNextDomain = SMTPDomainFindNext(CDomain) + + AccountName = CDomain.AccountName + DomainName = CDomain.DomainName + DomainRedirectionHosts = CDomain.DomainRedirectionHosts + DomainRedirectionStatus = CDomain.DomainRedirectionStatus + Status = CDomain.Status + + End Function + + Public Property DomainName() As String + Get + Return Me.DomainNameVal + End Get + Set(ByVal Value As String) + Me.DomainNameVal = Value + End Set + End Property + + Public Property Status() As Integer + Get + Return Me.StatusVal + End Get + Set(ByVal Value As Integer) + Me.StatusVal = Value + End Set + End Property + + Public Property DomainRedirectionStatus() As Integer + Get + Return Me.DomainRedirectionStatusVal + End Get + Set(ByVal Value As Integer) + Me.DomainRedirectionStatusVal = Value + End Set + End Property + + Public Property DomainRedirectionHosts() As String + Get + Return Me.DomainRedirectionHostsVal + End Get + Set(ByVal Value As String) + Me.DomainRedirectionHostsVal = Value + End Set + End Property + + Public Property AccountName() As String + Get + Return Me.AccountNameVal + End Get + Set(ByVal Value As String) + Me.AccountNameVal = Value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal Value As String) + Me.HostVal = Value + End Set + End Property + + Public Property RetainMode() As Integer + Get + Return Me.RetainModeVal + End Get + Set(ByVal Value As Integer) + Me.RetainModeVal = Value + End Set + End Property + + Public Property PollForMessages() As Integer + Get + Return Me.PollForMessagesVal + End Get + Set(ByVal Value As Integer) + Me.PollForMessagesVal = Value + End Set + End Property + + Public Property UpStreamHost() As String + Get + Return Me.UpStreamHostVal + End Get + Set(ByVal Value As String) + Me.UpStreamHostVal = Value + End Set + End Property + + Public Property PollInterval() As Integer + Get + Return Me.PollIntervalVal + End Get + Set(ByVal Value As Integer) + Me.PollIntervalVal = Value + End Set + End Property + + Public Property AliasMode() As Integer + Get + Return Me.AliasModeVal + End Get + Set(ByVal Value As Integer) + Me.AliasModeVal = Value + End Set + End Property + + Public Property AliasName() As String + Get + Return Me.AliasNameVal + End Get + Set(ByVal Value As String) + Me.AliasNameVal = Value + End Set + End Property + + Private Function CString(ByVal InString As String) As String + CString = InString & Chr(0) + End Function + + Private Function NonCString(ByVal InString As String) As String + Dim NTPos As Integer + NTPos = InStr(1, InString, Chr(0), CompareMethod.Binary) + If NTPos > 0 Then + NonCString = Left(InString, NTPos - 1) + Else + NonCString = InString + End If + + End Function + + Public Function Exists(ByVal DomainName As String) As Boolean + + Dim CDomain As New ISMTPDOMAINTYPE + + CDomain.AccountName = CString("") + CDomain.DomainName = CString(DomainName) + CDomain.DomainRedirectionHosts = CString("") + CDomain.DomainRedirectionStatus = -1 + CDomain.Status = -1 + + Exists = (SMTPDomainGet(CDomain) = 1) + + End Function + + Private Sub AddDataTableColumns(ByRef oTable As DataTable) + oTable.Columns.Add("DomainName", GetType(String)) + oTable.Columns.Add("Status", GetType(Long)) + oTable.Columns.Add("RedirectionStatus", GetType(Long)) + oTable.Columns.Add("RedirectionHosts", GetType(String)) + End Sub + + End Class +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableGroup.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableGroup.vb new file mode 100644 index 00000000..b60ade86 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableGroup.vb @@ -0,0 +1,219 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableGroup + Inherits MarshalByRefObject + + Private RecipientAddressVal As String + Private PostofficeVal As String + Private GroupNameVal As String + Private GroupFileVal As String + Private GroupStatusVal As Integer + Private HostVal As String + + Private Structure IGROUPTYPE + Public RecipientAddress As String + Public Postoffice As String + Public GroupName As String + Public GroupFile As String + Public GroupStatus As Integer + End Structure + + Private Declare Function GroupGet Lib "MEAIPO.DLL" (ByRef lpGroup As IGROUPTYPE) As Integer + Private Declare Function GroupFindFirst Lib "MEAIPO.DLL" (ByRef lpGroup As IGROUPTYPE) As Integer + Private Declare Function GroupFindNext Lib "MEAIPO.DLL" (ByRef lpGroup As IGROUPTYPE) As Integer + Private Declare Function GroupAdd Lib "MEAIPO.DLL" (ByRef lpGroup As IGROUPTYPE) As Integer + Private Declare Function GroupEdit Lib "MEAIPO.DLL" (ByRef TargetGroup As IGROUPTYPE, ByRef NewGroup As IGROUPTYPE) As Integer + Private Declare Function GroupRemove Lib "MEAIPO.DLL" (ByRef lpGroup As IGROUPTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAIPO.DLL" (ByVal CurrentHost As String) As Integer + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Public Function FindFirstGroup() As Integer + Dim CGroup As IGROUPTYPE + CGroup.GroupFile = GroupFile + CGroup.Postoffice = Postoffice + CGroup.GroupName = GroupName + CGroup.RecipientAddress = RecipientAddress + CGroup.GroupStatus = GroupStatus + FindFirstGroup = GroupFindFirst(CGroup) + GroupFile = CGroup.GroupFile + Postoffice = CGroup.Postoffice + GroupName = CGroup.GroupName + RecipientAddress = CGroup.RecipientAddress + GroupStatus = CGroup.GroupStatus + End Function + Public Function FindNextGroup() As Integer + Dim CGroup As IGROUPTYPE + CGroup.GroupFile = GroupFile + CGroup.Postoffice = Postoffice + CGroup.GroupName = GroupName + CGroup.RecipientAddress = RecipientAddress + CGroup.GroupStatus = GroupStatus + FindNextGroup = GroupFindNext(CGroup) + GroupFile = CGroup.GroupFile + Postoffice = CGroup.Postoffice + GroupName = CGroup.GroupName + RecipientAddress = CGroup.RecipientAddress + GroupStatus = CGroup.GroupStatus + End Function + + Public Function AddGroup() As Integer + Dim CGroup As IGROUPTYPE + CGroup.GroupFile = GroupFile + CGroup.Postoffice = Postoffice + CGroup.GroupName = GroupName + CGroup.RecipientAddress = RecipientAddress + CGroup.GroupStatus = GroupStatus + AddGroup = GroupAdd(CGroup) + GroupFile = CGroup.GroupFile + Postoffice = CGroup.Postoffice + GroupName = CGroup.GroupName + RecipientAddress = CGroup.RecipientAddress + GroupStatus = CGroup.GroupStatus + End Function + + Public Function GetGroup() As Integer + Dim CGroup As IGROUPTYPE + CGroup.GroupFile = GroupFile + CGroup.Postoffice = Postoffice + CGroup.GroupName = GroupName + CGroup.RecipientAddress = RecipientAddress + CGroup.GroupStatus = GroupStatus + GetGroup = GroupGet(CGroup) + GroupFile = CGroup.GroupFile + Postoffice = CGroup.Postoffice + GroupName = CGroup.GroupName + RecipientAddress = CGroup.RecipientAddress + GroupStatus = CGroup.GroupStatus + End Function + Public Function RemoveGroup() As Integer + Dim CGroup As IGROUPTYPE + CGroup.GroupFile = GroupFile + CGroup.Postoffice = Postoffice + CGroup.GroupName = GroupName + CGroup.RecipientAddress = RecipientAddress + CGroup.GroupStatus = GroupStatus + RemoveGroup = GroupRemove(CGroup) + GroupFile = CGroup.GroupFile + Postoffice = CGroup.Postoffice + GroupName = CGroup.GroupName + RecipientAddress = CGroup.RecipientAddress + GroupStatus = CGroup.GroupStatus + End Function + + Public Function EditGroup(ByVal NewRecipientAddress As String, ByVal NewPostoffice As String, ByVal NewGroupName As String, ByVal NewGroupFile As String, ByVal NewGroupStatus As Integer) As Integer + Dim CGroup As IGROUPTYPE + Dim CGroupData As IGROUPTYPE + ' Get the Find Stuff Set up + CGroup.GroupFile = GroupFile + CGroup.GroupName = GroupName + CGroup.Postoffice = Postoffice + CGroup.RecipientAddress = RecipientAddress + CGroup.GroupStatus = GroupStatus + ' Get the Data Set up + CGroupData.GroupFile = NewGroupFile + CGroupData.GroupName = NewGroupName + CGroupData.Postoffice = NewPostoffice + CGroupData.RecipientAddress = NewRecipientAddress + CGroupData.GroupStatus = NewGroupStatus + + EditGroup = GroupEdit(CGroup, CGroupData) + GroupFile = CGroupData.GroupFile + Postoffice = CGroupData.Postoffice + GroupName = CGroupData.GroupName + RecipientAddress = CGroupData.RecipientAddress + GroupStatus = CGroup.GroupStatus + End Function + + Private Sub AddDataTableColumns(ByRef oTable As DataTable) + oTable.Columns.Add("GroupName", GetType(String)) + oTable.Columns.Add("GroupStatus", GetType(Long)) + oTable.Columns.Add("RecipientAddress", GetType(String)) + End Sub + + Public Property RecipientAddress() As String + Get + Return Me.RecipientAddressVal + End Get + Set(ByVal value As String) + Me.RecipientAddressVal = value + End Set + End Property + + Public Property Postoffice() As String + Get + Return Me.PostofficeVal + End Get + Set(ByVal value As String) + Me.PostofficeVal = value + End Set + End Property + + Public Property GroupName() As String + Get + Return Me.GroupNameVal + End Get + Set(ByVal value As String) + Me.GroupNameVal = value + End Set + End Property + + Public Property GroupFile() As String + Get + Return Me.GroupFileVal + End Get + Set(ByVal value As String) + Me.GroupFileVal = value + End Set + End Property + + Public Property GroupStatus() As Integer + Get + Return Me.GroupStatusVal + End Get + Set(ByVal value As Integer) + Me.GroupStatusVal = value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal value As String) + Me.HostVal = value + End Set + End Property + End Class + +End Namespace \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableGroupMember.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableGroupMember.vb new file mode 100644 index 00000000..d01e8232 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableGroupMember.vb @@ -0,0 +1,169 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableGroupMember + Inherits MarshalByRefObject + + Private AddressVal As String + Private PostofficeVal As String + Private MailboxVal As String + Private HostVal As String + + Private Structure IGROUPMEMBERTYPE + Public Address As String + Public Postoffice As String + Public Mailbox As String + End Structure + + Private Declare Function GroupMemberGet Lib "MEAIPO.DLL" (ByRef lpGroupMember As IGROUPMEMBERTYPE) As Integer + Private Declare Function GroupMemberFindFirst Lib "MEAIPO.DLL" (ByRef lpGroupMember As IGROUPMEMBERTYPE) As Integer + Private Declare Function GroupMemberFindNext Lib "MEAIPO.DLL" (ByRef lpGroupMember As IGROUPMEMBERTYPE) As Integer + Private Declare Function GroupMemberAdd Lib "MEAIPO.DLL" (ByRef lpGroupMember As IGROUPMEMBERTYPE) As Integer + Private Declare Function GroupMemberEdit Lib "MEAIPO.DLL" (ByRef TargetGroupMember As IGROUPMEMBERTYPE, ByRef NewGroupMember As IGROUPMEMBERTYPE) As Integer + Private Declare Function GroupMemberRemove Lib "MEAIPO.DLL" (ByRef lpGroupMember As IGROUPMEMBERTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAIPO.DLL" (ByVal CurrentHost As String) As Integer + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + + Public Function FindFirstGroupMember() As Integer + Dim CGroupMember As IGROUPMEMBERTYPE + + CGroupMember.Address = Address + CGroupMember.Postoffice = Postoffice + CGroupMember.Mailbox = Mailbox + FindFirstGroupMember = GroupMemberFindFirst(CGroupMember) + Address = CGroupMember.Address + Postoffice = CGroupMember.Postoffice + Mailbox = CGroupMember.Mailbox + + End Function + + Public Function FindNextGroupMember() As Integer + Dim CGroupMember As IGROUPMEMBERTYPE + CGroupMember.Address = Address + CGroupMember.Postoffice = Postoffice + CGroupMember.Mailbox = Mailbox + FindNextGroupMember = GroupMemberFindNext(CGroupMember) + Address = CGroupMember.Address + Postoffice = CGroupMember.Postoffice + Mailbox = CGroupMember.Mailbox + End Function + + Public Function AddGroupMember() As Integer + Dim CGroupMember As IGROUPMEMBERTYPE + CGroupMember.Address = Address + CGroupMember.Postoffice = Postoffice + CGroupMember.Mailbox = Mailbox + AddGroupMember = GroupMemberAdd(CGroupMember) + Address = CGroupMember.Address + Postoffice = CGroupMember.Postoffice + Mailbox = CGroupMember.Mailbox + End Function + + Public Function GetGroupMember() As Integer + Dim CGroupMember As IGROUPMEMBERTYPE + CGroupMember.Address = Address + CGroupMember.Postoffice = Postoffice + CGroupMember.Mailbox = Mailbox + GetGroupMember = GroupMemberGet(CGroupMember) + Address = CGroupMember.Address + Postoffice = CGroupMember.Postoffice + Mailbox = CGroupMember.Mailbox + End Function + Public Function RemoveGroupMember() As Integer + Dim CGroupMember As IGROUPMEMBERTYPE + CGroupMember.Address = Address + CGroupMember.Postoffice = Postoffice + CGroupMember.Mailbox = Mailbox + RemoveGroupMember = GroupMemberRemove(CGroupMember) + Address = CGroupMember.Address + Postoffice = CGroupMember.Postoffice + Mailbox = CGroupMember.Mailbox + End Function + Public Function EditGroupMember(ByVal NewAddress As String, ByVal NewPostoffice As String, ByVal NewMailbox As String) As Integer + + Dim CGroupMember As IGROUPMEMBERTYPE + Dim CGroupMemberData As IGROUPMEMBERTYPE + ' Get the Find Stuff Set up + CGroupMember.Address = Address + CGroupMember.Postoffice = Postoffice + CGroupMember.Mailbox = Mailbox + ' Get the Data Set up + CGroupMemberData.Address = NewAddress + CGroupMemberData.Postoffice = NewPostoffice + CGroupMemberData.Mailbox = NewMailbox + EditGroupMember = GroupMemberEdit(CGroupMember, CGroupMemberData) + + CGroupMemberData.Address = CGroupMemberData.Address + CGroupMemberData.Postoffice = CGroupMemberData.Postoffice + CGroupMemberData.Mailbox = CGroupMemberData.Mailbox + End Function + + Public Property Address() As String + Get + Return Me.AddressVal + End Get + Set(ByVal value As String) + Me.AddressVal = value + End Set + End Property + + Public Property Postoffice() As String + Get + Return Me.PostofficeVal + End Get + Set(ByVal value As String) + Me.PostofficeVal = value + End Set + End Property + + Public Property Mailbox() As String + Get + Return Me.MailboxVal + End Get + Set(ByVal value As String) + Me.MailboxVal = value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal value As String) + Me.HostVal = value + End Set + End Property + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableList.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableList.vb new file mode 100644 index 00000000..56c9f5c8 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableList.vb @@ -0,0 +1,1134 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableList + Inherits MarshalByRefObject + + Private DescriptionVal As String + Private AccountNameVal As String + Private ListNameVal As String + Private ListTypeVal As Long + Private ListStatusVal As Long + Private ModeratorAddressVal As String + Private HeaderAnnotationStatusVal As Long + Private HeaderAnnotationVal As String + Private FooterAnnotationStatusVal As Long + Private FooterAnnotationVal As String + Private ListAddressVal As String + + ' + ' New Fields + ' + Private SubscribeMessageFileStatusVal As Long + Private SubscribeMessageFileVal As String + Private UnsubscribeMessageFileStatusVal As Long + Private UnsubscribeMessageFileVal As String + Private SubjectSuffixStatusVal As Long + Private SubjectSuffixVal As String + Private SubjectPrefixStatusVal As Long + Private SubjectPrefixVal As String + Private OwnerVal As String + Private HelpMessageFileStatusVal As Long + Private HelpMessageFileVal As String + Private RemovalMessageFileStatusVal As Long + Private RemovalMessageFileVal As String + Private ReplyToModeVal As Long + Private MaxMessageSizeVal As Long + Private PostingModeVal As Long + Private SubScriptionModeVal As Long + Private AuthenticationModeVal As Long + Private PasswordVal As String + Private DigestModeVal As Long + Private DigestMailboxVal As String + Private DigestAnnotationModeVal As Long + Private DigestAttachmentModeVal As Long + Private DigestMessageSeparationModeVal As Long + Private DigestSchedulingStatusVal As Long + Private DigestSchedulingModeVal As Long + Private DigestSchedulingIntervalVal As Long + Private FromAddressModeVal As Long + + ' + ' Host Fields + ' + Public Host As String + + Private Structure ILISTTYPE + Public ListName As String + Public AccountName As String + Public ListType As Integer + Public ModeratorAddress As String + Public ListStatus As Integer + Public Description As String + Public HeaderAnnotationStatus As Integer + Public HeaderAnnotation As String + Public FooterAnnotationStatus As Integer + Public FooterAnnotation As String + Public ListAddress As String + ' + ' New feilds + ' + Public SubscribeMessageFileStatus As Integer + Public SubscribeMessageFile As String + Public UnsubscribeMessageFileStatus As Integer + Public UnsubscribeMessageFile As String + Public SubjectSuffixStatus As Integer + Public SubjectSuffix As String + Public SubjectPrefixStatus As Integer + Public SubjectPrefix As String + Public Owner As String + Public HelpMessageFileStatus As Integer + Public HelpMessageFile As String + Public RemovalMessageFileStatus As Integer + Public RemovalMessageFile As String + Public ReplyToMode As Integer + Public MaxMessageSize As Integer + Public PostingMode As Integer + Public SubScriptionMode As Integer + Public AuthenticationMode As Integer + Public Password As String + Public DigestMode As Integer + Public DigestMailbox As String + Public DigestAnnotationMode As Integer + Public DigestAttachmentMode As Integer + Public DigestMessageSeparationMode As Integer + Public DigestSchedulingStatus As Integer + Public DigestSchedulingMode As Integer + Public DigestSchedulingInterval As Integer + Public FromAddressMode As Integer + End Structure + + + Private Declare Function ListGet Lib "MEAILS.DLL" (ByRef lpList As ILISTTYPE) As Integer + Private Declare Function ListFindFirst Lib "MEAILS.DLL" (ByRef lpList As ILISTTYPE) As Integer + Private Declare Function ListFindNext Lib "MEAILS.DLL" (ByRef lpList As ILISTTYPE) As Integer + Private Declare Function ListAdd Lib "MEAILS.DLL" (ByRef lpList As ILISTTYPE) As Integer + Private Declare Function ListEdit Lib "MEAILS.DLL" (ByRef TargetList As ILISTTYPE, ByRef NewList As ILISTTYPE) As Integer + Private Declare Function ListRemove Lib "MEAILS.DLL" (ByRef lpList As ILISTTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAILS.DLL" (ByVal CurrentHost As String) As Integer + + + Private Structure IANNOTATIONTYPE + Public AnnotationName As String + Public AccountName As String + Public AnnotationText As String + End Structure + + Private Declare Function AnnotationGet Lib "MEAILS.DLL" (ByRef lpAnnotation As IANNOTATIONTYPE) As Integer + Private Declare Function AnnotationAdd Lib "MEAILS.DLL" (ByRef lpAnnotation As IANNOTATIONTYPE) As Integer + Private Declare Function AnnotationRemove Lib "MEAILS.DLL" (ByRef lpAnnotation As IANNOTATIONTYPE) As Integer + + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Public Function FindFirstList() As Integer + Dim CList As ILISTTYPE + CList.ListType = ListType + CList.AccountName = AccountName + CList.ListName = ListName + CList.Description = Description + CList.ListStatus = ListStatus + CList.HeaderAnnotationStatus = HeaderAnnotationStatus + CList.HeaderAnnotation = HeaderAnnotation + CList.FooterAnnotationStatus = FooterAnnotationStatus + CList.FooterAnnotation = FooterAnnotation + CList.ModeratorAddress = ModeratorAddress + CList.ListAddress = ListAddress + CList.SubscribeMessageFileStatus = SubscribeMessageFileStatus + CList.SubscribeMessageFile = SubscribeMessageFile + CList.UnsubscribeMessageFileStatus = UnsubscribeMessageFileStatus + CList.UnsubscribeMessageFile = UnsubscribeMessageFile + CList.SubjectSuffixStatus = SubjectSuffixStatus + CList.SubjectSuffix = SubjectSuffix + CList.SubjectPrefixStatus = SubjectPrefixStatus + CList.SubjectPrefix = SubjectPrefix + CList.Owner = Owner + CList.HelpMessageFileStatus = HelpMessageFileStatus + CList.HelpMessageFile = HelpMessageFile + CList.RemovalMessageFileStatus = RemovalMessageFileStatus + CList.RemovalMessageFile = RemovalMessageFile + CList.ReplyToMode = ReplyToMode + CList.MaxMessageSize = MaxMessageSize + CList.PostingMode = PostingMode + CList.SubScriptionMode = SubScriptionMode + CList.AuthenticationMode = AuthenticationMode + CList.Password = Password + CList.DigestMode = DigestMode + CList.DigestMailbox = DigestMailbox + CList.DigestAnnotationMode = DigestAnnotationMode + CList.DigestAttachmentMode = DigestAttachmentMode + CList.DigestMessageSeparationMode = DigestMessageSeparationMode + CList.DigestSchedulingStatus = DigestSchedulingStatus + CList.DigestSchedulingMode = DigestSchedulingMode + CList.DigestSchedulingInterval = DigestSchedulingInterval + CList.FromAddressMode = FromAddressMode + ' + ' Make Call + ' + FindFirstList = ListFindFirst(CList) + ListType = CList.ListType + AccountName = CList.AccountName + ListName = CList.ListName + Description = CList.Description + ListStatus = CList.ListStatus + HeaderAnnotationStatus = CList.HeaderAnnotationStatus + HeaderAnnotation = CList.HeaderAnnotation + FooterAnnotationStatus = CList.FooterAnnotationStatus + FooterAnnotation = CList.FooterAnnotation + ModeratorAddress = CList.ModeratorAddress + ListAddress = CList.ListAddress + SubscribeMessageFileStatus = CList.SubscribeMessageFileStatus + SubscribeMessageFile = CList.SubscribeMessageFile + UnsubscribeMessageFileStatus = CList.UnsubscribeMessageFileStatus + UnsubscribeMessageFile = CList.UnsubscribeMessageFile + SubjectSuffixStatus = CList.SubjectSuffixStatus + SubjectSuffix = CList.SubjectSuffix + SubjectPrefixStatus = CList.SubjectPrefixStatus + SubjectPrefix = CList.SubjectPrefix + Owner = CList.Owner + HelpMessageFileStatus = CList.HelpMessageFileStatus + HelpMessageFile = CList.HelpMessageFile + RemovalMessageFileStatus = CList.RemovalMessageFileStatus + RemovalMessageFile = CList.RemovalMessageFile + ReplyToMode = CList.ReplyToMode + MaxMessageSize = CList.MaxMessageSize + PostingMode = CList.PostingMode + SubScriptionMode = CList.SubScriptionMode + AuthenticationMode = CList.AuthenticationMode + Password = CList.Password + DigestMode = CList.DigestMode + DigestMailbox = CList.DigestMailbox + DigestAnnotationMode = CList.DigestAnnotationMode + DigestAttachmentMode = CList.DigestAttachmentMode + DigestMessageSeparationMode = CList.DigestMessageSeparationMode + DigestSchedulingStatus = CList.DigestSchedulingStatus + DigestSchedulingMode = CList.DigestSchedulingMode + DigestSchedulingInterval = CList.DigestSchedulingInterval + FromAddressMode = CList.FromAddressMode + End Function + Public Function FindNextList() As Integer + Dim CList As ILISTTYPE + CList.ListType = ListType + CList.AccountName = AccountName + CList.ListName = ListName + CList.Description = Description + CList.ListStatus = ListStatus + CList.HeaderAnnotationStatus = HeaderAnnotationStatus + CList.HeaderAnnotation = HeaderAnnotation + CList.FooterAnnotationStatus = FooterAnnotationStatus + CList.FooterAnnotation = FooterAnnotation + CList.ModeratorAddress = ModeratorAddress + CList.ListAddress = ListAddress + CList.SubscribeMessageFileStatus = SubscribeMessageFileStatus + CList.SubscribeMessageFile = SubscribeMessageFile + CList.UnsubscribeMessageFileStatus = UnsubscribeMessageFileStatus + CList.UnsubscribeMessageFile = UnsubscribeMessageFile + CList.SubjectSuffixStatus = SubjectSuffixStatus + CList.SubjectSuffix = SubjectSuffix + CList.SubjectPrefixStatus = SubjectPrefixStatus + CList.SubjectPrefix = SubjectPrefix + CList.Owner = Owner + CList.HelpMessageFileStatus = HelpMessageFileStatus + CList.HelpMessageFile = HelpMessageFile + CList.RemovalMessageFileStatus = RemovalMessageFileStatus + CList.RemovalMessageFile = RemovalMessageFile + CList.ReplyToMode = ReplyToMode + CList.MaxMessageSize = MaxMessageSize + CList.PostingMode = PostingMode + CList.SubScriptionMode = SubScriptionMode + CList.AuthenticationMode = AuthenticationMode + CList.Password = Password + CList.DigestMode = DigestMode + CList.DigestMailbox = DigestMailbox + CList.DigestAnnotationMode = DigestAnnotationMode + CList.DigestAttachmentMode = DigestAttachmentMode + CList.DigestMessageSeparationMode = DigestMessageSeparationMode + CList.DigestSchedulingStatus = DigestSchedulingStatus + CList.DigestSchedulingMode = DigestSchedulingMode + CList.DigestSchedulingInterval = DigestSchedulingInterval + CList.FromAddressMode = FromAddressMode + ' + ' Make Call + ' + FindNextList = ListFindNext(CList) + ListType = CList.ListType + AccountName = CList.AccountName + ListName = CList.ListName + Description = CList.Description + ListStatus = CList.ListStatus + HeaderAnnotationStatus = CList.HeaderAnnotationStatus + HeaderAnnotation = CList.HeaderAnnotation + FooterAnnotationStatus = CList.FooterAnnotationStatus + FooterAnnotation = CList.FooterAnnotation + ModeratorAddress = CList.ModeratorAddress + ListAddress = CList.ListAddress + SubscribeMessageFileStatus = CList.SubscribeMessageFileStatus + SubscribeMessageFile = CList.SubscribeMessageFile + UnsubscribeMessageFileStatus = CList.UnsubscribeMessageFileStatus + UnsubscribeMessageFile = CList.UnsubscribeMessageFile + SubjectSuffixStatus = CList.SubjectSuffixStatus + SubjectSuffix = CList.SubjectSuffix + SubjectPrefixStatus = CList.SubjectPrefixStatus + SubjectPrefix = CList.SubjectPrefix + Owner = CList.Owner + HelpMessageFileStatus = CList.HelpMessageFileStatus + HelpMessageFile = CList.HelpMessageFile + RemovalMessageFileStatus = CList.RemovalMessageFileStatus + RemovalMessageFile = CList.RemovalMessageFile + ReplyToMode = CList.ReplyToMode + MaxMessageSize = CList.MaxMessageSize + PostingMode = CList.PostingMode + SubScriptionMode = CList.SubScriptionMode + AuthenticationMode = CList.AuthenticationMode + Password = CList.Password + DigestMode = CList.DigestMode + DigestMailbox = CList.DigestMailbox + DigestAnnotationMode = CList.DigestAnnotationMode + DigestAttachmentMode = CList.DigestAttachmentMode + DigestMessageSeparationMode = CList.DigestMessageSeparationMode + DigestSchedulingStatus = CList.DigestSchedulingStatus + DigestSchedulingMode = CList.DigestSchedulingMode + DigestSchedulingInterval = CList.DigestSchedulingInterval + FromAddressMode = CList.FromAddressMode + End Function + + Public Function AddList() As Integer + Dim CList As ILISTTYPE + CList.ListType = ListType + CList.AccountName = AccountName + CList.ListName = ListName + CList.Description = Description + CList.ListStatus = ListStatus + CList.HeaderAnnotationStatus = HeaderAnnotationStatus + CList.HeaderAnnotation = HeaderAnnotation + CList.FooterAnnotationStatus = FooterAnnotationStatus + CList.FooterAnnotation = FooterAnnotation + CList.ModeratorAddress = ModeratorAddress + CList.ListAddress = ListAddress + CList.SubscribeMessageFileStatus = SubscribeMessageFileStatus + CList.SubscribeMessageFile = SubscribeMessageFile + CList.UnsubscribeMessageFileStatus = UnsubscribeMessageFileStatus + CList.UnsubscribeMessageFile = UnsubscribeMessageFile + CList.SubjectSuffixStatus = SubjectSuffixStatus + CList.SubjectSuffix = SubjectSuffix + CList.SubjectPrefixStatus = SubjectPrefixStatus + CList.SubjectPrefix = SubjectPrefix + CList.Owner = Owner + CList.HelpMessageFileStatus = HelpMessageFileStatus + CList.HelpMessageFile = HelpMessageFile + CList.RemovalMessageFileStatus = RemovalMessageFileStatus + CList.RemovalMessageFile = RemovalMessageFile + CList.ReplyToMode = ReplyToMode + CList.MaxMessageSize = MaxMessageSize + CList.PostingMode = PostingMode + CList.SubScriptionMode = SubScriptionMode + CList.AuthenticationMode = AuthenticationMode + CList.Password = Password + CList.DigestMode = DigestMode + CList.DigestMailbox = DigestMailbox + CList.DigestAnnotationMode = DigestAnnotationMode + CList.DigestAttachmentMode = DigestAttachmentMode + CList.DigestMessageSeparationMode = DigestMessageSeparationMode + CList.DigestSchedulingStatus = DigestSchedulingStatus + CList.DigestSchedulingMode = DigestSchedulingMode + CList.DigestSchedulingInterval = DigestSchedulingInterval + CList.FromAddressMode = FromAddressMode + ' + ' Make Call + ' + AddList = ListAdd(CList) + ListType = CList.ListType + AccountName = CList.AccountName + ListName = CList.ListName + Description = CList.Description + ListStatus = CList.ListStatus + HeaderAnnotationStatus = CList.HeaderAnnotationStatus + HeaderAnnotation = CList.HeaderAnnotation + FooterAnnotationStatus = CList.FooterAnnotationStatus + FooterAnnotation = CList.FooterAnnotation + ModeratorAddress = CList.ModeratorAddress + ListAddress = CList.ListAddress + SubscribeMessageFileStatus = CList.SubscribeMessageFileStatus + SubscribeMessageFile = CList.SubscribeMessageFile + UnsubscribeMessageFileStatus = CList.UnsubscribeMessageFileStatus + UnsubscribeMessageFile = CList.UnsubscribeMessageFile + SubjectSuffixStatus = CList.SubjectSuffixStatus + SubjectSuffix = CList.SubjectSuffix + SubjectPrefixStatus = CList.SubjectPrefixStatus + SubjectPrefix = CList.SubjectPrefix + Owner = CList.Owner + HelpMessageFileStatus = CList.HelpMessageFileStatus + HelpMessageFile = CList.HelpMessageFile + RemovalMessageFileStatus = CList.RemovalMessageFileStatus + RemovalMessageFile = CList.RemovalMessageFile + ReplyToMode = CList.ReplyToMode + MaxMessageSize = CList.MaxMessageSize + PostingMode = CList.PostingMode + SubScriptionMode = CList.SubScriptionMode + AuthenticationMode = CList.AuthenticationMode + Password = CList.Password + DigestMode = CList.DigestMode + DigestMailbox = CList.DigestMailbox + DigestAnnotationMode = CList.DigestAnnotationMode + DigestAttachmentMode = CList.DigestAttachmentMode + DigestMessageSeparationMode = CList.DigestMessageSeparationMode + DigestSchedulingStatus = CList.DigestSchedulingStatus + DigestSchedulingMode = CList.DigestSchedulingMode + DigestSchedulingInterval = CList.DigestSchedulingInterval + FromAddressMode = CList.FromAddressMode + End Function + + Public Function GetList() As Integer + Dim CList As ILISTTYPE + CList.ListType = ListType + CList.AccountName = AccountName + CList.ListName = ListName + CList.Description = Description + CList.ListStatus = ListStatus + CList.HeaderAnnotationStatus = HeaderAnnotationStatus + CList.HeaderAnnotation = HeaderAnnotation + CList.FooterAnnotationStatus = FooterAnnotationStatus + CList.FooterAnnotation = FooterAnnotation + CList.ModeratorAddress = ModeratorAddress + CList.ListAddress = ListAddress + CList.SubscribeMessageFileStatus = SubscribeMessageFileStatus + CList.SubscribeMessageFile = SubscribeMessageFile + CList.UnsubscribeMessageFileStatus = UnsubscribeMessageFileStatus + CList.UnsubscribeMessageFile = UnsubscribeMessageFile + CList.SubjectSuffixStatus = SubjectSuffixStatus + CList.SubjectSuffix = SubjectSuffix + CList.SubjectPrefixStatus = SubjectPrefixStatus + CList.SubjectPrefix = SubjectPrefix + CList.Owner = Owner + CList.HelpMessageFileStatus = HelpMessageFileStatus + CList.HelpMessageFile = HelpMessageFile + CList.RemovalMessageFileStatus = RemovalMessageFileStatus + CList.RemovalMessageFile = RemovalMessageFile + CList.ReplyToMode = ReplyToMode + CList.MaxMessageSize = MaxMessageSize + CList.PostingMode = PostingMode + CList.SubScriptionMode = SubScriptionMode + CList.AuthenticationMode = AuthenticationMode + CList.Password = Password + CList.DigestMode = DigestMode + CList.DigestMailbox = DigestMailbox + CList.DigestAnnotationMode = DigestAnnotationMode + CList.DigestAttachmentMode = DigestAttachmentMode + CList.DigestMessageSeparationMode = DigestMessageSeparationMode + CList.DigestSchedulingStatus = DigestSchedulingStatus + CList.DigestSchedulingMode = DigestSchedulingMode + CList.DigestSchedulingInterval = DigestSchedulingInterval + CList.FromAddressMode = FromAddressMode + ' + ' Make Call + ' + GetList = ListGet(CList) + ListType = CList.ListType + AccountName = CList.AccountName + ListName = CList.ListName + Description = CList.Description + ListStatus = CList.ListStatus + HeaderAnnotationStatus = CList.HeaderAnnotationStatus + HeaderAnnotation = CList.HeaderAnnotation + FooterAnnotationStatus = CList.FooterAnnotationStatus + FooterAnnotation = CList.FooterAnnotation + ModeratorAddress = CList.ModeratorAddress + ListAddress = CList.ListAddress + 'new + SubscribeMessageFileStatus = CList.SubscribeMessageFileStatus + SubscribeMessageFile = CList.SubscribeMessageFile + UnsubscribeMessageFileStatus = CList.UnsubscribeMessageFileStatus + UnsubscribeMessageFile = CList.UnsubscribeMessageFile + SubjectSuffixStatus = CList.SubjectSuffixStatus + SubjectSuffix = CList.SubjectSuffix + SubjectPrefixStatus = CList.SubjectPrefixStatus + SubjectPrefix = CList.SubjectPrefix + Owner = CList.Owner + HelpMessageFileStatus = CList.HelpMessageFileStatus + HelpMessageFile = CList.HelpMessageFile + RemovalMessageFileStatus = CList.RemovalMessageFileStatus + RemovalMessageFile = CList.RemovalMessageFile + ReplyToMode = CList.ReplyToMode + MaxMessageSize = CList.MaxMessageSize + PostingMode = CList.PostingMode + SubScriptionMode = CList.SubScriptionMode + AuthenticationMode = CList.AuthenticationMode + Password = CList.Password + DigestMode = CList.DigestMode + DigestMailbox = CList.DigestMailbox + DigestAnnotationMode = CList.DigestAnnotationMode + DigestAttachmentMode = CList.DigestAttachmentMode + DigestMessageSeparationMode = CList.DigestMessageSeparationMode + DigestSchedulingStatus = CList.DigestSchedulingStatus + DigestSchedulingMode = CList.DigestSchedulingMode + DigestSchedulingInterval = CList.DigestSchedulingInterval + FromAddressMode = CList.FromAddressMode + End Function + Public Function RemoveList() As Integer + Dim CList As ILISTTYPE + CList.ListType = ListType + CList.AccountName = AccountName + CList.ListName = ListName + CList.Description = Description + CList.ListStatus = ListStatus + CList.HeaderAnnotationStatus = HeaderAnnotationStatus + CList.HeaderAnnotation = HeaderAnnotation + CList.FooterAnnotationStatus = FooterAnnotationStatus + CList.FooterAnnotation = FooterAnnotation + CList.ModeratorAddress = ModeratorAddress + CList.ListAddress = ListAddress + CList.SubscribeMessageFileStatus = SubscribeMessageFileStatus + CList.SubscribeMessageFile = SubscribeMessageFile + CList.UnsubscribeMessageFileStatus = UnsubscribeMessageFileStatus + CList.UnsubscribeMessageFile = UnsubscribeMessageFile + CList.SubjectSuffixStatus = SubjectSuffixStatus + CList.SubjectSuffix = SubjectSuffix + CList.SubjectPrefixStatus = SubjectPrefixStatus + CList.SubjectPrefix = SubjectPrefix + CList.Owner = Owner + CList.HelpMessageFileStatus = HelpMessageFileStatus + CList.HelpMessageFile = HelpMessageFile + CList.RemovalMessageFileStatus = RemovalMessageFileStatus + CList.RemovalMessageFile = RemovalMessageFile + CList.ReplyToMode = ReplyToMode + CList.MaxMessageSize = MaxMessageSize + CList.PostingMode = PostingMode + CList.SubScriptionMode = SubScriptionMode + CList.AuthenticationMode = AuthenticationMode + CList.Password = Password + CList.DigestMode = DigestMode + CList.DigestMailbox = DigestMailbox + CList.DigestAnnotationMode = DigestAnnotationMode + CList.DigestAttachmentMode = DigestAttachmentMode + CList.DigestMessageSeparationMode = DigestMessageSeparationMode + CList.DigestSchedulingStatus = DigestSchedulingStatus + CList.DigestSchedulingMode = DigestSchedulingMode + CList.DigestSchedulingInterval = DigestSchedulingInterval + CList.FromAddressMode = FromAddressMode + ' + ' Make Call + ' + RemoveList = ListRemove(CList) + ListType = CList.ListType + AccountName = CList.AccountName + ListName = CList.ListName + Description = CList.Description + ListStatus = CList.ListStatus + HeaderAnnotationStatus = CList.HeaderAnnotationStatus + HeaderAnnotation = CList.HeaderAnnotation + FooterAnnotationStatus = CList.FooterAnnotationStatus + FooterAnnotation = CList.FooterAnnotation + ModeratorAddress = CList.ModeratorAddress + ListAddress = CList.ListAddress + SubscribeMessageFileStatus = CList.SubscribeMessageFileStatus + SubscribeMessageFile = CList.SubscribeMessageFile + UnsubscribeMessageFileStatus = CList.UnsubscribeMessageFileStatus + UnsubscribeMessageFile = CList.UnsubscribeMessageFile + SubjectSuffixStatus = CList.SubjectSuffixStatus + SubjectSuffix = CList.SubjectSuffix + SubjectPrefixStatus = CList.SubjectPrefixStatus + SubjectPrefix = CList.SubjectPrefix + Owner = CList.Owner + HelpMessageFileStatus = CList.HelpMessageFileStatus + HelpMessageFile = CList.HelpMessageFile + RemovalMessageFileStatus = CList.RemovalMessageFileStatus + RemovalMessageFile = CList.RemovalMessageFile + ReplyToMode = CList.ReplyToMode + MaxMessageSize = CList.MaxMessageSize + PostingMode = CList.PostingMode + SubScriptionMode = CList.SubScriptionMode + AuthenticationMode = CList.AuthenticationMode + Password = CList.Password + DigestMode = CList.DigestMode + DigestMailbox = CList.DigestMailbox + DigestAnnotationMode = CList.DigestAnnotationMode + DigestAttachmentMode = CList.DigestAttachmentMode + DigestMessageSeparationMode = CList.DigestMessageSeparationMode + DigestSchedulingStatus = CList.DigestSchedulingStatus + DigestSchedulingMode = CList.DigestSchedulingMode + DigestSchedulingInterval = CList.DigestSchedulingInterval + FromAddressMode = CList.FromAddressMode + End Function + + Public Function EditList(ByVal NewDescription As String, ByVal NewAccountName As String, ByVal NewListName As String, ByVal NewListType As Long, ByVal NewListStatus As Long, ByVal NewHeaderAnnotationStatus As Long, ByVal NewHeaderAnnotation As String, ByVal NewFooterAnnotationStatus As Long, ByVal NewFooterAnnotation As String, ByVal NewModeratorAddress As String, ByVal NewListAddress As String, _ + Optional ByVal NewSubscribeMessageFileStatus As Long = -1, Optional ByVal NewSubscribeMessageFile As String = "(Nil)", Optional ByVal NewUnsubscribeMessageFileStatus As Long = -1, Optional ByVal NewUnsubscribeMessageFile As String = "(Nil)", Optional ByVal NewSubjectSuffixStatus As Long = -1, Optional ByVal NewSubjectSuffix As String = "(Nil)", Optional ByVal NewSubjectPrefixStatus As Long = -1, Optional ByVal NewSubjectPrefix As String = "(Nil)", Optional ByVal NewOwner As String = "(Nil)", Optional ByVal NewHelpMessageFileStatus As Long = -1, _ + Optional ByVal NewHelpMessageFile As String = "(Nil)", Optional ByVal NewRemovalMessageFileStatus As Long = -1, Optional ByVal NewRemovalMessageFile As String = "(Nil)", Optional ByVal NewReplyToMode As Long = -1, Optional ByVal NewMaxMessageSize As Long = -1, Optional ByVal NewPostingMode As Long = -1, Optional ByVal NewSubScriptionMode As Long = -1, Optional ByVal NewAuthenticationMode As Long = -1, Optional ByVal NewPassword As String = "(Nil)", Optional ByVal NewDigestMode As Long = -1, Optional ByVal NewDigestMailbox As String = "(Nil)", _ + Optional ByVal NewDigestAnnotationMode As Long = -1, Optional ByVal NewDigestAttachmentMode As Long = -1, Optional ByVal NewDigestMessageSeparationMode As Long = -1, Optional ByVal NewDigestSchedulingStatus As Long = -1, _ + Optional ByVal NewDigestSchedulingMode As Long = -1, Optional ByVal NewDigestSchedulingInterval As Long = -1, Optional ByVal NewFromAddressMode As Long = -1) As Integer + ' + ' hmm - if we pass these with default values of Blank, then how will we know whether or not to clear then or not? + ' + ' + Dim CList As ILISTTYPE + Dim CListData As ILISTTYPE + ' Get the Find Stuff Set up + CList.ListType = ListType + CList.ListName = ListName + CList.AccountName = AccountName + CList.Description = Description + CList.ListStatus = ListStatus + CList.HeaderAnnotationStatus = HeaderAnnotationStatus + CList.HeaderAnnotation = HeaderAnnotation + CList.FooterAnnotationStatus = FooterAnnotationStatus + CList.FooterAnnotation = FooterAnnotation + CList.ModeratorAddress = ModeratorAddress + CList.ListAddress = ListAddress + CList.SubscribeMessageFileStatus = SubscribeMessageFileStatus + CList.SubscribeMessageFile = SubscribeMessageFile + CList.UnsubscribeMessageFileStatus = UnsubscribeMessageFileStatus + CList.UnsubscribeMessageFile = UnsubscribeMessageFile + CList.SubjectSuffixStatus = SubjectSuffixStatus + CList.SubjectSuffix = SubjectSuffix + CList.SubjectPrefixStatus = SubjectPrefixStatus + CList.SubjectPrefix = SubjectPrefix + CList.Owner = Owner + CList.HelpMessageFileStatus = HelpMessageFileStatus + CList.HelpMessageFile = HelpMessageFile + CList.RemovalMessageFileStatus = RemovalMessageFileStatus + CList.RemovalMessageFile = RemovalMessageFile + CList.ReplyToMode = ReplyToMode + CList.MaxMessageSize = MaxMessageSize + CList.PostingMode = PostingMode + CList.SubScriptionMode = SubScriptionMode + CList.AuthenticationMode = AuthenticationMode + CList.Password = Password + CList.DigestMode = DigestMode + CList.DigestMailbox = DigestMailbox + CList.DigestAnnotationMode = DigestAnnotationMode + CList.DigestAttachmentMode = DigestAttachmentMode + CList.DigestMessageSeparationMode = DigestMessageSeparationMode + CList.DigestSchedulingStatus = DigestSchedulingStatus + CList.DigestSchedulingMode = DigestSchedulingMode + CList.DigestSchedulingInterval = DigestSchedulingInterval + CList.FromAddressMode = FromAddressMode + ' Get the Data Set up + CListData.ListType = NewListType + CListData.ListName = NewListName + CListData.AccountName = NewAccountName + CListData.Description = NewDescription + CListData.ListStatus = NewListStatus 'NewHeaderAnnotationStatus As Long, NewHeaderAnnotation As String, NewFooterAnnotationStatus As Long, NewFooterAnnotation As String,NewModeratorAddress As String + CListData.HeaderAnnotationStatus = NewHeaderAnnotationStatus + CListData.HeaderAnnotation = NewHeaderAnnotation + CListData.FooterAnnotationStatus = NewFooterAnnotationStatus + CListData.FooterAnnotation = NewFooterAnnotation + CListData.ModeratorAddress = NewModeratorAddress + CListData.ListAddress = NewListAddress + CListData.SubscribeMessageFileStatus = NewSubscribeMessageFileStatus + CListData.SubscribeMessageFile = NewSubscribeMessageFile + CListData.UnsubscribeMessageFileStatus = NewUnsubscribeMessageFileStatus + CListData.UnsubscribeMessageFile = NewUnsubscribeMessageFile + CListData.SubjectSuffixStatus = NewSubjectSuffixStatus + CListData.SubjectSuffix = NewSubjectSuffix + CListData.SubjectPrefixStatus = NewSubjectPrefixStatus + CListData.SubjectPrefix = NewSubjectPrefix + CListData.Owner = NewOwner + CListData.HelpMessageFileStatus = NewHelpMessageFileStatus + CListData.HelpMessageFile = NewHelpMessageFile + CListData.RemovalMessageFileStatus = NewRemovalMessageFileStatus + CListData.RemovalMessageFile = NewRemovalMessageFile + CListData.ReplyToMode = NewReplyToMode + CListData.MaxMessageSize = NewMaxMessageSize + CListData.PostingMode = NewPostingMode + CListData.SubScriptionMode = NewSubScriptionMode + CListData.AuthenticationMode = NewAuthenticationMode + CListData.Password = NewPassword + CListData.DigestMode = NewDigestMode + CListData.DigestMailbox = NewDigestMailbox + CListData.DigestAnnotationMode = NewDigestAnnotationMode + CListData.DigestAttachmentMode = NewDigestAttachmentMode + CListData.DigestMessageSeparationMode = NewDigestMessageSeparationMode + CListData.DigestSchedulingStatus = NewDigestSchedulingStatus + CListData.DigestSchedulingMode = NewDigestSchedulingMode + CListData.DigestSchedulingInterval = NewDigestSchedulingInterval + CListData.FromAddressMode = NewFromAddressMode + ' + ' Make the Call + ' + EditList = ListEdit(CList, CListData) + ListType = CListData.ListType + AccountName = CListData.AccountName + ListName = CListData.ListName + Description = CListData.Description + ListStatus = CList.ListStatus + HeaderAnnotationStatus = CList.HeaderAnnotationStatus + HeaderAnnotation = CList.HeaderAnnotation + FooterAnnotationStatus = CList.FooterAnnotationStatus + FooterAnnotation = CList.FooterAnnotation + ModeratorAddress = CList.ModeratorAddress + ListAddress = CList.ListAddress + SubscribeMessageFileStatus = CList.SubscribeMessageFileStatus + SubscribeMessageFile = CList.SubscribeMessageFile + UnsubscribeMessageFileStatus = CList.UnsubscribeMessageFileStatus + UnsubscribeMessageFile = CList.UnsubscribeMessageFile + SubjectSuffixStatus = CList.SubjectSuffixStatus + SubjectSuffix = CList.SubjectSuffix + SubjectPrefixStatus = CList.SubjectPrefixStatus + SubjectPrefix = CList.SubjectPrefix + Owner = CList.Owner + HelpMessageFileStatus = CList.HelpMessageFileStatus + HelpMessageFile = CList.HelpMessageFile + RemovalMessageFileStatus = CList.RemovalMessageFileStatus + RemovalMessageFile = CList.RemovalMessageFile + ReplyToMode = CList.ReplyToMode + MaxMessageSize = CList.MaxMessageSize + PostingMode = CList.PostingMode + SubScriptionMode = CList.SubScriptionMode + AuthenticationMode = CList.AuthenticationMode + Password = CList.Password + DigestMode = CList.DigestMode + DigestMailbox = CList.DigestMailbox + DigestAnnotationMode = CList.DigestAnnotationMode + DigestAttachmentMode = CList.DigestAttachmentMode + DigestMessageSeparationMode = CList.DigestMessageSeparationMode + DigestSchedulingStatus = CList.DigestSchedulingStatus + DigestSchedulingMode = CList.DigestSchedulingMode + DigestSchedulingInterval = CList.DigestSchedulingInterval + FromAddressMode = CList.FromAddressMode + End Function + ' + ' We need to wrapper these routines + ' + Function SetHeader(ByVal Postoffice As String, ByVal List As String, ByVal ListHeader As String) As Integer + + Dim CAnnotation As IANNOTATIONTYPE + + CAnnotation.AccountName = Postoffice + CAnnotation.AnnotationName = List & "-HEADER" + CAnnotation.AnnotationText = ListHeader + SetHeader = AnnotationAdd(CAnnotation) + + End Function + + Function GetHeader(ByVal Postoffice As String, ByVal List As String) As String + + Dim CAnnotation As IANNOTATIONTYPE + CAnnotation.AnnotationText = "" + + CAnnotation.AccountName = Postoffice + CAnnotation.AnnotationName = List & "-HEADER" + If (AnnotationGet(CAnnotation) = 1) Then + GetHeader = CAnnotation.AnnotationText + Else + GetHeader = "" + End If + + End Function + + Function SetFooter(ByVal Postoffice As String, ByVal List As String, ByVal ListFooter As String) As Integer + + Dim CAnnotation As IANNOTATIONTYPE + + CAnnotation.AccountName = Postoffice + CAnnotation.AnnotationName = List & "-FOOTER" + CAnnotation.AnnotationText = ListFooter + SetFooter = AnnotationAdd(CAnnotation) + + End Function + + Public Function GetFooter(ByVal Postoffice As String, ByVal List As String) As String + + Dim CAnnotation As IANNOTATIONTYPE + + CAnnotation.AccountName = Postoffice + CAnnotation.AnnotationName = List & "-FOOTER" + CAnnotation.AnnotationText = "" + + If (AnnotationGet(CAnnotation) = 1) Then + GetFooter = CAnnotation.AnnotationText + Else + GetFooter = "" + End If + + End Function + + Private Sub AddDataTableColumns(ByRef oTable As DataTable) + oTable.Columns.Add("ListName", GetType(String)) + oTable.Columns.Add("ListStatus", GetType(Long)) + oTable.Columns.Add("Description", GetType(String)) + oTable.Columns.Add("ListType", GetType(Long)) + End Sub + + + Public Property Description() As String + Get + Return Me.DescriptionVal + End Get + Set(ByVal value As String) + Me.DescriptionVal = value + End Set + End Property + + Public Property AccountName() As String + Get + Return Me.AccountNameVal + End Get + Set(ByVal value As String) + Me.AccountNameVal = value + End Set + End Property + + Public Property ListName() As String + Get + Return Me.ListNameVal + End Get + Set(ByVal value As String) + Me.ListNameVal = value + End Set + End Property + + Public Property ListType() As Long + Get + Return Me.ListTypeVal + End Get + Set(ByVal value As Long) + Me.ListTypeVal = value + End Set + End Property + + Public Property ListStatus() As Long + Get + Return Me.ListStatusVal + End Get + Set(ByVal value As Long) + Me.ListStatusVal = value + End Set + End Property + + Public Property ModeratorAddress() As String + Get + Return Me.ModeratorAddressVal + End Get + Set(ByVal value As String) + Me.ModeratorAddressVal = value + End Set + End Property + + Public Property HeaderAnnotationStatus() As Long + Get + Return Me.HeaderAnnotationStatusVal + End Get + Set(ByVal value As Long) + Me.HeaderAnnotationStatusVal = value + End Set + End Property + + Public Property HeaderAnnotation() As String + Get + Return Me.HeaderAnnotationVal + End Get + Set(ByVal value As String) + Me.HeaderAnnotationVal = value + End Set + End Property + + Public Property FooterAnnotationStatus() As Long + Get + Return Me.FooterAnnotationStatusVal + End Get + Set(ByVal value As Long) + Me.FooterAnnotationStatusVal = value + End Set + End Property + + Public Property FooterAnnotation() As String + Get + Return Me.FooterAnnotationVal + End Get + Set(ByVal value As String) + Me.FooterAnnotationVal = value + End Set + End Property + + Public Property ListAddress() As String + Get + Return Me.ListAddressVal + End Get + Set(ByVal value As String) + Me.ListAddressVal = value + End Set + End Property + + Public Property SubscribeMessageFileStatus() As Long + Get + Return Me.SubscribeMessageFileStatusVal + End Get + Set(ByVal value As Long) + Me.SubscribeMessageFileStatusVal = value + End Set + End Property + + Public Property SubscribeMessageFile() As String + Get + Return Me.SubscribeMessageFileVal + End Get + Set(ByVal value As String) + Me.SubscribeMessageFileVal = value + End Set + End Property + + Public Property UnsubscribeMessageFileStatus() As Long + Get + Return Me.UnsubscribeMessageFileStatusVal + End Get + Set(ByVal value As Long) + Me.UnsubscribeMessageFileStatusVal = value + End Set + End Property + + Public Property UnsubscribeMessageFile() As String + Get + Return Me.UnsubscribeMessageFileVal + End Get + Set(ByVal value As String) + Me.UnsubscribeMessageFileVal = value + End Set + End Property + + Public Property SubjectSuffixStatus() As Long + Get + Return Me.SubjectSuffixStatusVal + End Get + Set(ByVal value As Long) + Me.SubjectSuffixStatusVal = value + End Set + End Property + + Public Property SubjectSuffix() As String + Get + Return Me.SubjectSuffixVal + End Get + Set(ByVal value As String) + Me.SubjectSuffixVal = value + End Set + End Property + + Public Property SubjectPrefixStatus() As Long + Get + Return Me.SubjectPrefixStatusVal + End Get + Set(ByVal value As Long) + Me.SubjectPrefixStatusVal = value + End Set + End Property + + Public Property SubjectPrefix() As String + Get + Return Me.SubjectPrefixVal + End Get + Set(ByVal value As String) + Me.SubjectPrefixVal = value + End Set + End Property + + Public Property Owner() As String + Get + Return Me.OwnerVal + End Get + Set(ByVal value As String) + Me.OwnerVal = value + End Set + End Property + + Public Property HelpMessageFileStatus() As Long + Get + Return Me.HelpMessageFileStatusVal + End Get + Set(ByVal value As Long) + Me.HelpMessageFileStatusVal = value + End Set + End Property + + Public Property HelpMessageFile() As String + Get + Return Me.HelpMessageFileVal + End Get + Set(ByVal value As String) + Me.HelpMessageFileVal = value + End Set + End Property + + Public Property RemovalMessageFileStatus() As Long + Get + Return Me.RemovalMessageFileStatusVal + End Get + Set(ByVal value As Long) + Me.RemovalMessageFileStatusVal = value + End Set + End Property + + Public Property RemovalMessageFile() As String + Get + Return Me.RemovalMessageFileVal + End Get + Set(ByVal value As String) + Me.RemovalMessageFileVal = value + End Set + End Property + + Public Property ReplyToMode() As Long + Get + Return Me.ReplyToModeVal + End Get + Set(ByVal value As Long) + Me.ReplyToModeVal = value + End Set + End Property + + Public Property MaxMessageSize() As Long + Get + Return Me.MaxMessageSizeVal + End Get + Set(ByVal value As Long) + Me.MaxMessageSizeVal = value + End Set + End Property + + Public Property PostingMode() As Long + Get + Return Me.PostingModeVal + End Get + Set(ByVal value As Long) + Me.PostingModeVal = value + End Set + End Property + + Public Property SubScriptionMode() As Long + Get + Return Me.SubScriptionModeVal + End Get + Set(ByVal value As Long) + Me.SubScriptionModeVal = value + End Set + End Property + + Public Property AuthenticationMode() As Long + Get + Return Me.AuthenticationModeVal + End Get + Set(ByVal value As Long) + Me.AuthenticationModeVal = value + End Set + End Property + + Public Property Password() As String + Get + Return Me.PasswordVal + End Get + Set(ByVal value As String) + Me.PasswordVal = value + End Set + End Property + + Public Property DigestMode() As Long + Get + Return Me.DigestModeVal + End Get + Set(ByVal value As Long) + Me.DigestModeVal = value + End Set + End Property + + Public Property DigestMailbox() As String + Get + Return Me.DigestMailboxVal + End Get + Set(ByVal value As String) + Me.DigestMailboxVal = value + End Set + End Property + + Public Property DigestAnnotationMode() As Long + Get + Return Me.DigestAnnotationModeVal + End Get + Set(ByVal value As Long) + Me.DigestAnnotationModeVal = value + End Set + End Property + + Public Property DigestAttachmentMode() As Long + Get + Return Me.DigestAttachmentModeVal + End Get + Set(ByVal value As Long) + Me.DigestAttachmentModeVal = value + End Set + End Property + + Public Property DigestMessageSeparationMode() As Long + Get + Return Me.DigestMessageSeparationModeVal + End Get + Set(ByVal value As Long) + Me.DigestMessageSeparationModeVal = value + End Set + End Property + + Public Property DigestSchedulingStatus() As Long + Get + Return Me.DigestSchedulingStatusVal + End Get + Set(ByVal value As Long) + Me.DigestSchedulingStatusVal = value + End Set + End Property + + Public Property DigestSchedulingMode() As Long + Get + Return Me.DigestSchedulingModeVal + End Get + Set(ByVal value As Long) + Me.DigestSchedulingModeVal = value + End Set + End Property + + Public Property DigestSchedulingInterval() As Long + Get + Return Me.DigestSchedulingIntervalVal + End Get + Set(ByVal value As Long) + Me.DigestSchedulingIntervalVal = value + End Set + End Property + + Public Property FromAddressMode() As Long + Get + Return Me.FromAddressModeVal + End Get + Set(ByVal value As Long) + Me.FromAddressModeVal = value + End Set + End Property + + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableListMember.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableListMember.vb new file mode 100644 index 00000000..0b43ddac --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableListMember.vb @@ -0,0 +1,192 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableListMember + Inherits MarshalByRefObject + + Private AddressVal As String + Private AccountNameVal As String + Private ListNameVal As String + Private ListMemberTypeVal As Long + Private StatusVal As Long + Private HostVal As String + + + Private Structure ILISTMEMBERTYPE + Public Address As String + Public AccountName As String + Public ListName As String + Public Role As Integer + Public Status As Integer + End Structure + + + Private Declare Function ListMemberGet Lib "MEAILS.DLL" (ByRef lpListMember As ILISTMEMBERTYPE) As Integer + Private Declare Function ListMemberFindFirst Lib "MEAILS.DLL" (ByRef lpListMember As ILISTMEMBERTYPE) As Integer + Private Declare Function ListMemberFindNext Lib "MEAILS.DLL" (ByRef lpListMember As ILISTMEMBERTYPE) As Integer + Private Declare Function ListMemberAdd Lib "MEAILS.DLL" (ByRef lpListMember As ILISTMEMBERTYPE) As Integer + Private Declare Function ListMemberEdit Lib "MEAILS.DLL" (ByRef TargetListMember As ILISTMEMBERTYPE, ByRef NewListMember As ILISTMEMBERTYPE) As Integer + Private Declare Function ListMemberRemove Lib "MEAILS.DLL" (ByRef lpListMember As ILISTMEMBERTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAILS.DLL" (ByVal CurrentHost As String) As Integer + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + + Public Function FindFirstListMember() As Integer + Dim CListMember As ILISTMEMBERTYPE + CListMember.Address = Address + CListMember.AccountName = AccountName + CListMember.ListName = ListName + FindFirstListMember = ListMemberFindFirst(CListMember) + Address = CListMember.Address + AccountName = CListMember.AccountName + ListName = CListMember.ListName + End Function + + Public Function FindNextListMember() As Integer + Dim CListMember As ILISTMEMBERTYPE + CListMember.Address = Address + CListMember.AccountName = AccountName + CListMember.ListName = ListName + FindNextListMember = ListMemberFindNext(CListMember) + Address = CListMember.Address + AccountName = CListMember.AccountName + ListName = CListMember.ListName + End Function + + Public Function AddListMember() As Integer + Dim CListMember As ILISTMEMBERTYPE + CListMember.Address = Address + CListMember.AccountName = AccountName + CListMember.ListName = ListName + AddListMember = ListMemberAdd(CListMember) + Address = CListMember.Address + AccountName = CListMember.AccountName + ListName = CListMember.ListName + End Function + + Public Function GetListMember() As Integer + Dim CListMember As ILISTMEMBERTYPE + CListMember.Address = Address + CListMember.AccountName = AccountName + CListMember.ListName = ListName + GetListMember = ListMemberGet(CListMember) + Address = CListMember.Address + AccountName = CListMember.AccountName + ListName = CListMember.ListName + End Function + Public Function RemoveListMember() As Integer + Dim CListMember As ILISTMEMBERTYPE + CListMember.Address = Address + CListMember.AccountName = AccountName + CListMember.ListName = ListName + RemoveListMember = ListMemberRemove(CListMember) + Address = CListMember.Address + AccountName = CListMember.AccountName + ListName = CListMember.ListName + End Function + + Public Function EditListMember(ByVal NewAddress, ByVal NewAccountName, ByVal NewListName, ByVal NewListMemberType, ByVal NewStatus) As Integer + Dim CListMember As ILISTMEMBERTYPE + Dim CListMemberData As ILISTMEMBERTYPE + ' Get the Find Stuff Set up + CListMember.Address = Address + CListMember.AccountName = AccountName + CListMember.ListName = ListName + ' Get the Data Set up + CListMemberData.Address = NewAddress + CListMemberData.AccountName = NewAccountName + CListMemberData.ListName = NewListName + EditListMember = ListMemberEdit(CListMember, CListMemberData) + + NewAddress = CListMemberData.Address + NewAccountName = CListMemberData.AccountName + NewListName = CListMemberData.ListName + End Function + + Public Property Address() As String + Get + Return Me.AddressVal + End Get + Set(ByVal value As String) + Me.AddressVal = value + End Set + End Property + + Public Property AccountName() As String + Get + Return Me.AccountNameVal + End Get + Set(ByVal value As String) + Me.AccountNameVal = value + End Set + End Property + + Public Property ListName() As String + Get + Return Me.ListNameVal + End Get + Set(ByVal value As String) + Me.ListNameVal = value + End Set + End Property + + Public Property ListMemberType() As Long + Get + Return Me.ListMemberTypeVal + End Get + Set(ByVal value As Long) + Me.ListMemberTypeVal = value + End Set + End Property + + Public Property Status() As Long + Get + Return Me.StatusVal + End Get + Set(ByVal value As Long) + Me.StatusVal = value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal value As String) + Me.HostVal = value + End Set + End Property + + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableLogin.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableLogin.vb new file mode 100644 index 00000000..5ac6d0de --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableLogin.vb @@ -0,0 +1,292 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableLogin + Inherits MarshalByRefObject + + Private UserNameVal As String + Private StatusVal As Long + Private PasswordVal As String + Private AccountVal As String + Private DescriptionVal As String + Private LoginAttemptsVal As Long + Private LastAttemptVal As Long + Private LastSuccessfulLoginVal As Long + Private RightsVal As String + Private HostVal As String + + Private Structure IAUTHENTRYTYPE + Public UserName As String + Public Status As Integer + Public Password As String + Public Account As String + Public Rights As String + Public Description As String + Public LoginAttempts As Integer + Public LastAttempt As Integer + Public LastSuccessfulLogin As Integer + End Structure + + Private Declare Function GetLastProviderErrorCode Lib "MEAIAU.DLL" Alias "GetLastErrorCode" () As Integer + Private Declare Function LoginGet Lib "MEAIAU.DLL" (ByRef lpLogin As IAUTHENTRYTYPE) As Integer + Private Declare Function LoginFindFirst Lib "MEAIAU.DLL" (ByRef lpLogin As IAUTHENTRYTYPE) As Integer + Private Declare Function LoginFindNext Lib "MEAIAU.DLL" (ByRef lpLogin As IAUTHENTRYTYPE) As Integer + Private Declare Function LoginAdd Lib "MEAIAU.DLL" (ByRef lpLogin As IAUTHENTRYTYPE) As Integer + Private Declare Function LoginEdit Lib "MEAIAU.DLL" (ByRef TargetLogin As IAUTHENTRYTYPE, ByRef NewLogin As IAUTHENTRYTYPE) As Integer + Private Declare Function LoginRemove Lib "MEAIAU.DLL" (ByRef lpLogin As IAUTHENTRYTYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAIAU.DLL" (ByVal CurrentHost As String) As Integer + + Public Function GetLastErrorCode() As Integer + Return GetLastProviderErrorCode() + End Function + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Public Function GetLogin() As Integer + Dim CLogin As IAUTHENTRYTYPE + CLogin.UserName = UserName + CLogin.Password = Password + CLogin.Status = Status + CLogin.Account = Account + CLogin.Description = Description + CLogin.Rights = Rights + GetLogin = LoginGet(CLogin) + UserName = CLogin.UserName + Password = CLogin.Password + Status = CLogin.Status + Account = CLogin.Account + Description = CLogin.Description + Rights = CLogin.Rights + End Function + + Public Function FindFirstLogin() As Integer + + Dim CLogin As IAUTHENTRYTYPE + + CLogin.UserName = UserName + CLogin.Password = Password + CLogin.Status = Status + CLogin.Account = Account + CLogin.Description = Description + CLogin.Rights = Rights + FindFirstLogin = LoginFindFirst(CLogin) + UserName = CLogin.UserName + Password = CLogin.Password + Status = CLogin.Status + Account = CLogin.Account + Description = CLogin.Description + Rights = CLogin.Rights + End Function + + Public Function FindNextLogin() As Integer + Dim CLogin As IAUTHENTRYTYPE + CLogin.UserName = UserName + CLogin.Password = Password + CLogin.Status = Status + CLogin.Account = Account + CLogin.Description = Description + CLogin.Rights = Rights + FindNextLogin = LoginFindNext(CLogin) + UserName = CLogin.UserName + Password = CLogin.Password + Status = CLogin.Status + Account = CLogin.Account + Description = CLogin.Description + Rights = CLogin.Rights + End Function + + Public Function AddLogin() As Integer + Dim CLogin As IAUTHENTRYTYPE + CLogin.UserName = UserName + CLogin.Password = Password + CLogin.Status = Status + CLogin.Account = Account + CLogin.Description = Description + CLogin.Rights = Rights + AddLogin = LoginAdd(CLogin) + UserName = CLogin.UserName + Password = CLogin.Password + Status = CLogin.Status + Account = CLogin.Account + Description = CLogin.Description + Rights = CLogin.Rights + End Function + + Public Function RemoveLogin() As Integer + Dim CLogin As IAUTHENTRYTYPE + CLogin.UserName = UserName + CLogin.Password = Password + CLogin.Status = Status + CLogin.Account = Account + CLogin.Description = Description + CLogin.Rights = Rights + RemoveLogin = LoginRemove(CLogin) + End Function + + Public Function EditLogin(ByVal NewUserName As String, ByVal NewStatus As Long, ByVal NewPassword As String, ByVal NewAccount As String, ByVal NewDescription As String, ByVal NewLoginAttempts As Long, ByVal NewLastAttempt As Long, ByVal NewLastSuccessfulLogin As Long, ByVal NewRights As String) As Integer + Dim CLogin As IAUTHENTRYTYPE + Dim CLoginData As IAUTHENTRYTYPE + CLogin.UserName = UserName + CLogin.Password = Password + CLogin.Status = Status + CLogin.Account = Account + CLogin.Description = Description + CLogin.Rights = Rights + ' + CLoginData.UserName = NewUserName + CLoginData.Password = NewPassword + CLoginData.Status = NewStatus + CLoginData.Account = NewAccount + CLoginData.Description = NewDescription + CLoginData.Rights = NewRights + EditLogin = LoginEdit(CLogin, CLoginData) + End Function + + Private Function CString(ByVal InString As String) As String + CString = InString & Chr(0) + End Function + + Private Function NonCString(ByVal InString As String) As String + Dim NTPos As Integer + NTPos = InStr(1, InString, Chr(0), CompareMethod.Binary) + If NTPos > 0 Then + NonCString = Left(InString, NTPos - 1) + Else + NonCString = InString + End If + + End Function + + Public Function Exists(ByVal sUsername As String) As Boolean + Dim CLogin As IAUTHENTRYTYPE + CLogin.UserName = CString(sUsername) + CLogin.Password = CString("") + CLogin.Status = -1 + CLogin.Account = CString("") + CLogin.Description = CString("") + CLogin.Rights = CString("") + Exists = (LoginGet(CLogin) = 1) + End Function + + + Public Property UserName() As String + Get + Return Me.UserNameVal + End Get + Set(ByVal value As String) + Me.UserNameVal = value + End Set + End Property + + Public Property Status() As Long + Get + Return Me.StatusVal + End Get + Set(ByVal value As Long) + Me.StatusVal = value + End Set + End Property + + Public Property Password() As String + Get + Return Me.PasswordVal + End Get + Set(ByVal value As String) + Me.PasswordVal = value + End Set + End Property + + Public Property Account() As String + Get + Return Me.AccountVal + End Get + Set(ByVal value As String) + Me.AccountVal = value + End Set + End Property + + Public Property Description() As String + Get + Return Me.DescriptionVal + End Get + Set(ByVal value As String) + Me.DescriptionVal = value + End Set + End Property + + Public Property LoginAttempts() As Long + Get + Return Me.LoginAttemptsVal + End Get + Set(ByVal value As Long) + Me.LoginAttemptsVal = value + End Set + End Property + + Public Property LastAttempt() As Long + Get + Return Me.LastAttemptVal + End Get + Set(ByVal value As Long) + Me.LastAttemptVal = value + End Set + End Property + + Public Property LastSuccessfulLogin() As Long + Get + Return Me.LastSuccessfulLoginVal + End Get + Set(ByVal value As Long) + Me.LastSuccessfulLoginVal = value + End Set + End Property + + Public Property Rights() As String + Get + Return Me.RightsVal + End Get + Set(ByVal value As String) + Me.RightsVal = value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal value As String) + Me.HostVal = value + End Set + End Property + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableMailbox.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableMailbox.vb new file mode 100644 index 00000000..0f79485b --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableMailbox.vb @@ -0,0 +1,476 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Imports System.IO +Imports Microsoft.Win32 + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableMailbox + Inherits MarshalByRefObject + + Private PostofficeVal As String + Private MailboxNameVal As String + Private RedirectAddressVal As String + Private RedirectStatusVal As Long + Private StatusVal As Long + Private LimitVal As Long + Private SizeVal As Long + Private HostVal As String + + + Private Structure IMAILBOXTYPE + Public Postoffice As String + Public Mailbox As String + Public RedirectAddress As String + Public RedirectStatus As Integer + Public Status As Integer + Public Limit As Integer + Public Size As Integer + End Structure + + + Private Declare Function MailboxGet Lib "MEAIPO.DLL" (ByRef lpMailbox As IMAILBOXTYPE) As Integer + Private Declare Function MailboxGetLength Lib "MEAIPO.DLL" (ByRef lpMailbox As IMAILBOXTYPE) As Integer + Private Declare Function MailboxFindFirst Lib "MEAIPO.DLL" (ByRef lpMailbox As IMAILBOXTYPE) As Integer + Private Declare Function MailboxFindNext Lib "MEAIPO.DLL" (ByRef lpMailbox As IMAILBOXTYPE) As Integer + Private Declare Function MailboxAdd Lib "MEAIPO.DLL" (ByRef lpMailbox As IMAILBOXTYPE) As Integer + Private Declare Function MailboxEdit Lib "MEAIPO.DLL" (ByRef TargetMailbox As IMAILBOXTYPE, ByRef NewMailbox As IMAILBOXTYPE) As Integer + Private Declare Function MailboxRemove Lib "MEAIPO.DLL" (ByRef lpMailbox As IMAILBOXTYPE) As Integer + + Private Declare Function SetCurrentHost Lib "MEAIPO.DLL" (ByVal CurrentHost As String) As Integer + + Private Structure IANNOTATIONTYPE + Public AnnotationName As String + Public AccountName As String + Public AnnotationText As String + End Structure + + Private Declare Function AnnotationGet Lib "MEAILS.DLL" (ByRef lpAnnotation As IANNOTATIONTYPE) As Integer + Private Declare Function AnnotationAdd Lib "MEAILS.DLL" (ByRef lpAnnotation As IANNOTATIONTYPE) As Integer + Private Declare Function AnnotationRemove Lib "MEAILS.DLL" (ByRef lpAnnotation As IANNOTATIONTYPE) As Integer + + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Public Function FindFirstMailbox() As Integer + Dim CMailBox As IMAILBOXTYPE + CMailBox.Mailbox = MailboxName + CMailBox.Postoffice = Postoffice + CMailBox.RedirectAddress = RedirectAddress + CMailBox.RedirectStatus = RedirectStatus + CMailBox.Status = Status + CMailBox.Limit = Limit + CMailBox.Size = Size + FindFirstMailbox = MailboxFindFirst(CMailBox) + MailboxName = CMailBox.Mailbox + Postoffice = CMailBox.Postoffice + RedirectAddress = CMailBox.RedirectAddress + RedirectStatus = CMailBox.RedirectStatus + Status = CMailBox.Status + Limit = CMailBox.Limit + Size = CMailBox.Size + End Function + + + Public Function FindNextMailbox() As Integer + Dim CMailBox As IMAILBOXTYPE + CMailBox.Mailbox = MailboxName + CMailBox.Postoffice = Postoffice + CMailBox.RedirectAddress = RedirectAddress + CMailBox.RedirectStatus = RedirectStatus + CMailBox.Status = Status + CMailBox.Limit = Limit + CMailBox.Size = Size + FindNextMailbox = MailboxFindNext(CMailBox) + MailboxName = CMailBox.Mailbox + Postoffice = CMailBox.Postoffice + RedirectAddress = CMailBox.RedirectAddress + RedirectStatus = CMailBox.RedirectStatus + Status = CMailBox.Status + Limit = CMailBox.Limit + Size = CMailBox.Size + End Function + + Public Function AddMailbox() As Integer + Dim CMailBox As IMAILBOXTYPE + CMailBox.Mailbox = MailboxName + CMailBox.Postoffice = Postoffice + CMailBox.RedirectAddress = RedirectAddress + CMailBox.RedirectStatus = RedirectStatus + CMailBox.Status = Status + CMailBox.Limit = Limit + CMailBox.Size = Size + AddMailbox = MailboxAdd(CMailBox) + MailboxName = CMailBox.Mailbox + Postoffice = CMailBox.Postoffice + RedirectAddress = CMailBox.RedirectAddress + RedirectStatus = CMailBox.RedirectStatus + Status = CMailBox.Status + Limit = CMailBox.Limit + Size = CMailBox.Size + End Function + + Public Function GetMailbox() As Integer + Dim CMailBox As IMAILBOXTYPE + CMailBox.Mailbox = MailboxName + CMailBox.Postoffice = Postoffice + CMailBox.RedirectAddress = RedirectAddress + CMailBox.RedirectStatus = RedirectStatus + CMailBox.Status = Status + CMailBox.Limit = Limit + CMailBox.Size = Size + GetMailbox = MailboxGet(CMailBox) + MailboxName = CMailBox.Mailbox + Postoffice = CMailBox.Postoffice + RedirectAddress = CMailBox.RedirectAddress + RedirectStatus = CMailBox.RedirectStatus + Status = CMailBox.Status + Limit = CMailBox.Limit + Size = CMailBox.Size + End Function + + + Public Function RemoveMailbox() As Integer + Dim CMailBox As IMAILBOXTYPE + CMailBox.Mailbox = MailboxName + CMailBox.Postoffice = Postoffice + CMailBox.RedirectAddress = RedirectAddress + CMailBox.RedirectStatus = RedirectStatus + CMailBox.Status = Status + CMailBox.Limit = Limit + CMailBox.Size = Size + RemoveMailbox = MailboxRemove(CMailBox) + MailboxName = CMailBox.Mailbox + Postoffice = CMailBox.Postoffice + RedirectAddress = CMailBox.RedirectAddress + RedirectStatus = CMailBox.RedirectStatus + Status = CMailBox.Status + Limit = CMailBox.Limit + Size = CMailBox.Size + End Function + + + Public Function EditMailbox(ByVal NewPostoffice As String, ByVal NewMailbox As String, ByVal NewRedirectAddress As String, ByVal NewRedirectStatus As Long, ByVal NewStatus As Long, ByVal NewLimit As Long, ByVal NewSize As Long) As Integer + Dim CMailBox As IMAILBOXTYPE + Dim CMailBoxData As IMAILBOXTYPE + ' Get the Find Stuff Set up + CMailBox.Mailbox = MailboxName + CMailBox.Postoffice = Postoffice + CMailBox.RedirectAddress = RedirectAddress + CMailBox.RedirectStatus = RedirectStatus + CMailBox.Status = Status + CMailBox.Limit = Limit + CMailBox.Size = Size + ' Get the Data Set up + CMailBoxData.Mailbox = NewMailbox + CMailBoxData.Postoffice = NewPostoffice + CMailBoxData.RedirectAddress = NewRedirectAddress + CMailBoxData.RedirectStatus = NewRedirectStatus + CMailBoxData.Status = NewStatus + CMailBoxData.Limit = NewLimit + CMailBoxData.Size = NewSize + EditMailbox = MailboxEdit(CMailBox, CMailBoxData) + MailboxName = CMailBox.Mailbox + Postoffice = CMailBox.Postoffice + RedirectAddress = CMailBox.RedirectAddress + RedirectStatus = CMailBox.RedirectStatus + + End Function + + Public Function GetLength() As Integer + Dim CMailBox As IMAILBOXTYPE + CMailBox.Mailbox = MailboxName + CMailBox.Postoffice = Postoffice + CMailBox.RedirectAddress = RedirectAddress + CMailBox.RedirectStatus = RedirectStatus + CMailBox.Status = Status + CMailBox.Limit = Limit + CMailBox.Size = Size + Return MailboxGetLength(CMailBox) + End Function + + + Public Function SetAutoResponderStatus(ByVal bEnabled As Boolean) As Integer + Return SetAutoResponderStatus(Me.Postoffice, Me.MailboxName, bEnabled) + End Function + + Public Shared Function SetAutoResponderStatus(ByVal sPostoffice As String, ByVal sMailbox As String, ByVal bEnabled As Boolean) As Integer + ' + ' This function copies the Auto Responder Config File to indicate Enabled. + ' It deletes the CFG file to Disable + ' + Dim SourcePath As String + Dim TargetPath As String + + On Error Resume Next + + If (bEnabled) Then + ' + ' Copy AUTORESPOND.CF_ to AUTORESPOND.CFG + ' + SourcePath = MailEnable.GetPostofficesPath() & "\" & sPostoffice & "\MAILROOT\" & sMailbox & "\AUTORESPOND.CF_" + TargetPath = MailEnable.GetPostofficesPath() & "\" & sPostoffice & "\MAILROOT\" & sMailbox & "\AUTORESPOND.CFG" + + If Not File.Exists(SourcePath) Then + Return 1 + End If + + File.Copy(SourcePath, TargetPath, True) + SetAutoResponderStatus = 1 + Else + SourcePath = MailEnable.GetPostofficesPath() & "\" & sPostoffice & "\MAILROOT\" & sMailbox & "\AUTORESPOND.CFG" + + If Not File.Exists(SourcePath) Then + Return 1 + End If + + File.Delete(SourcePath) + SetAutoResponderStatus = 1 + End If + + End Function + + + Public Function SetAutoResponderContents(ByVal Headers As String, ByVal MessageBody As String) As Integer + Return SetAutoResponderContents(Me.Postoffice, Me.MailboxName, Headers, MessageBody) + End Function + + Public Shared Function SetAutoResponderContents(ByVal sPostoffice As String, ByVal sMailbox As String, ByVal Headers As String, ByVal MessageBody As String) As Integer + ' + ' This function sets the contents of the autoresponse. + ' The SetAutoResponderStatus routine must be called after this to make the changes effective + ' + Dim SourcePath As String + + SourcePath = MailEnable.GetPostofficesPath() & "\" & sPostoffice & "\MAILROOT\" & sMailbox & "\AUTORESPOND.CF_" + + On Error Resume Next + + Dim oTS As StreamWriter = New StreamWriter(SourcePath, False) + + If Err.Number = 0 Then + oTS.Write(Headers & vbCrLf & vbCrLf & MessageBody) + oTS.Close() + SetAutoResponderContents = 1 + Else + SetAutoResponderContents = 0 + End If + + End Function + + Public Function GetAutoResponderSubject() As String + ' + ' This Routine returns the current AutoResponder Subject + ' + Dim FileContents As String + Dim DelimiterPos As Long + Dim StartPos As Long + Dim EndPos As Long + Dim SubjectOffset As Long + Dim SourcePath As String + + SourcePath = MailEnable.GetPostofficesPath() & "\" & Me.Postoffice & "\MAILROOT\" & Me.MailboxName & "\AUTORESPOND.CF_" + + On Error Resume Next + + If Not File.Exists(SourcePath) Then + Return "" + End If + + Dim oTS As StreamReader = New StreamReader(SourcePath) + + FileContents = oTS.ReadToEnd + oTS.Close() + + DelimiterPos = InStr(1, FileContents, "Subject:") + + If DelimiterPos > 0 Then + SubjectOffset = Len("Subject: ") + StartPos = DelimiterPos + SubjectOffset + EndPos = InStr(DelimiterPos, FileContents, vbCrLf, ) + GetAutoResponderSubject = Mid(FileContents, StartPos, (EndPos - StartPos)) + Else + GetAutoResponderSubject = FileContents + End If + + End Function + + Public Function GetAutoResponderContents() As String + ' + ' This Routine returns the current AutoResponder Message + ' + Dim FileContents As String + Dim DelimiterPos As Long + Dim SourcePath As String + + SourcePath = MailEnable.GetPostofficesPath() & "\" & Me.Postoffice & "\MAILROOT\" & Me.MailboxName & "\AUTORESPOND.CF_" + + On Error Resume Next + + If Not File.Exists(SourcePath) Then + Return "" + End If + + Dim oTS As StreamReader = New StreamReader(SourcePath) + + FileContents = oTS.ReadToEnd + oTS.Close() + + DelimiterPos = InStr(1, FileContents, vbCrLf & vbCrLf) + + If DelimiterPos > 0 Then + ' It has headers + ' Headers = Mid(FileContents, 1, DelimiterPos + Len(vbCrLf & vbCrLf)) + GetAutoResponderContents = Mid$(FileContents, DelimiterPos + Len(vbCrLf & vbCrLf)) + Else + 'Headers = "" + GetAutoResponderContents = FileContents + End If + + End Function + + Public Function GetAutoResponderStatus() As Boolean + ' + ' This Routine returns the current AutoResponder Status + ' + Dim SourcePath As String + + SourcePath = MailEnable.GetPostofficesPath() & "\" & Me.Postoffice & "\MAILROOT\" & Me.MailboxName & "\AUTORESPOND.CFG" + + On Error Resume Next + + GetAutoResponderStatus = System.IO.File.Exists(SourcePath) + + End Function + + + + Function SetSignature(ByVal Postoffice As String, ByVal Mailbox As String, ByVal SignitureText As String) As Integer + Dim CAnnotation As IANNOTATIONTYPE + CAnnotation.AccountName = Postoffice + CAnnotation.AnnotationName = Mailbox & "-AUTOSIG" + CAnnotation.AnnotationText = SignitureText + SetSignature = AnnotationAdd(CAnnotation) + End Function + + Function GetSignature(ByVal Postoffice As String, ByVal Mailbox As String) As String + + Dim CAnnotation As IANNOTATIONTYPE + + CAnnotation.AccountName = Postoffice + CAnnotation.AnnotationName = Mailbox & "-AUTOSIG" + CAnnotation.AnnotationText = "" + + If (AnnotationGet(CAnnotation) = 1) Then + GetSignature = CAnnotation.AnnotationText + Else + GetSignature = "" + End If + End Function + + + Public Property Postoffice() As String + Get + Return Me.PostofficeVal + End Get + Set(ByVal value As String) + Me.PostofficeVal = value + End Set + End Property + + Public Property MailboxName() As String + Get + Return Me.MailboxNameVal + End Get + Set(ByVal value As String) + Me.MailboxNameVal = value + End Set + End Property + + Public Property RedirectAddress() As String + Get + Return Me.RedirectAddressVal + End Get + Set(ByVal value As String) + Me.RedirectAddressVal = value + End Set + End Property + + Public Property RedirectStatus() As Long + Get + Return Me.RedirectStatusVal + End Get + Set(ByVal value As Long) + Me.RedirectStatusVal = value + End Set + End Property + + Public Property Status() As Long + Get + Return Me.StatusVal + End Get + Set(ByVal value As Long) + Me.StatusVal = value + End Set + End Property + + Public Property Limit() As Long + Get + Return Me.LimitVal + End Get + Set(ByVal value As Long) + Me.LimitVal = value + End Set + End Property + + Public Property Size() As Long + Get + Return Me.SizeVal + End Get + Set(ByVal value As Long) + Me.SizeVal = value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal value As String) + Me.HostVal = value + End Set + End Property + + + + End Class + +End Namespace \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableOption.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableOption.vb new file mode 100644 index 00000000..66e39568 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnableOption.vb @@ -0,0 +1,194 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnableOption + Inherits MarshalByRefObject + + Private ScopeVal As Integer + Private QueryVal As String + Private ValueNameVal As String + Private ValueVal As String + Private HostVal As String + + Private Declare Function SystemGetOption Lib "MEAISO.DLL" Alias "GetOption" (ByVal Scope As Integer, ByVal Query As String, ByVal ValueName As String, ByVal ReturnValue As String) As Int32 + Private Declare Function SystemSetOption Lib "MEAISO.DLL" Alias "SetOption" (ByVal Scope As Integer, ByVal Query As String, ByVal ValueName As String, ByVal ReturnValue As String) As Int32 + Private Declare Function SetCurrentHost Lib "MEAISO.DLL" (ByVal CurrentHost As String) As Int32 + + Private Shared Function NonCString(ByVal InString As String) As String + Dim NTPos As Integer + NTPos = InStr(1, InString, Chr(0), CompareMethod.Binary) + If NTPos > 0 Then + NonCString = Left(InString, NTPos - 1) + Else + NonCString = InString + End If + End Function + + Private Shared Function CString(ByVal InString As String) As String + CString = InString & Chr(0) + End Function + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + Private Function ValidData() As Boolean + If Len(Query) >= 1024 Then ValidData = False : Exit Function + If Len(ValueName) >= 1024 Then ValidData = False : Exit Function + If Len(Value) >= 1024 Then ValidData = False : Exit Function + ValidData = True + End Function + + + Public Function GetOption() As Integer + If Not ValidData() Then GetOption = 0 : Exit Function + + Value = Space(2048) + Try + GetOption = SystemGetOption(Scope, Query, ValueName, Value) + Value = NonCString(Value) + Catch ex As Exception + GetOption = 0 + Value = String.Empty + End Try + End Function + + Public Function SetOption() As Integer + If Not ValidData() Then SetOption = 0 : Exit Function + + SetOption = SystemSetOption(Scope, Query, ValueName, Value) + End Function + + + Public Property Scope() As Integer + Get + Return Me.ScopeVal + End Get + Set(ByVal value As Integer) + Me.ScopeVal = value + End Set + End Property + + Public Property Query() As String + Get + Return Me.QueryVal + End Get + Set(ByVal value As String) + Me.QueryVal = value + End Set + End Property + + Public Property ValueName() As String + Get + Return Me.ValueNameVal + End Get + Set(ByVal value As String) + Me.ValueNameVal = value + End Set + End Property + + Public Property Value() As String + Get + Return Me.ValueVal + End Get + Set(ByVal value As String) + Me.ValueVal = value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal value As String) + Me.HostVal = value + End Set + End Property + + + Public Shared Function GetSystemOption(ByRef lScope As String, ByRef sQuery As String, ByRef sValueName As String, Optional ByVal DefaultValue As String = "") As String + + Dim oMEAOSO As New MailEnableOption + + On Error Resume Next + oMEAOSO.Scope = lScope + oMEAOSO.Query = sQuery + oMEAOSO.ValueName = sValueName + If oMEAOSO.GetOption() <> 0 Then + GetSystemOption = oMEAOSO.Value + Else + GetSystemOption = DefaultValue + End If + oMEAOSO = Nothing + + End Function + + Public Shared Function SetSystemOption(ByRef lScope As String, ByRef sQuery As String, ByRef sValueName As String, ByRef sValue As String) As Integer + + On Error Resume Next + + If Not IsNothing(sValue) Then + Dim oMEAOSO As New MailEnableOption + + oMEAOSO.Scope = lScope + oMEAOSO.Query = sQuery + oMEAOSO.ValueName = sValueName + oMEAOSO.Value = sValue + oMEAOSO.SetOption() + SetSystemOption = True + + oMEAOSO = Nothing + Return 1 + End If + + Return 0 + + End Function + + Public Shared Function GetRemoteRegistryString(ByVal HostName As String, ByVal ParentKey As String, ByVal RegistryKey As String, ByRef KeyValue As String) As Integer + If HostName Is Nothing Then + HostName = "" + End If + Dim LocalValue As String = Space(4096) + Dim Result As Integer = _GetRemoteRegistryString(HostName, ParentKey, RegistryKey, LocalValue) + If Result = 1 Then + KeyValue = NonCString(LocalValue) + End If + Return Result + End Function + + Private Declare Function GetRemoteRegistryWord Lib "MEAISO.DLL" (ByVal HostName As String, ByVal ParentKey As String, ByVal RegistryKey As String, ByVal KeyValue As Integer) As Integer + Private Declare Function SetRemoteRegistryWord Lib "MEAISO.DLL" (ByVal HostName As String, ByVal ParentKey As String, ByVal RegistryKey As String, ByVal KeyValue As Integer) As Integer + Private Declare Function SetRemoteRegistryString Lib "MEAISO.DLL" (ByVal HostName As String, ByVal ParentKey As String, ByVal RegistryKey As String, ByVal KeyValue As String) As Integer + Private Declare Function _GetRemoteRegistryString Lib "MEAISO.DLL" Alias "GetRemoteRegistryString" (ByVal HostName As String, ByVal ParentKey As String, ByVal RegistryKey As String, ByVal KeyValue As String) As Integer + + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnablePostoffice.vb b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnablePostoffice.vb new file mode 100644 index 00000000..fcfdd71d --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/MailEnablePostoffice.vb @@ -0,0 +1,172 @@ +' Copyright (c) 2011, Outercurve Foundation. +' All rights reserved. +' +' Redistribution and use in source and binary forms, with or without modification, +' are permitted provided that the following conditions are met: +' +' - Redistributions of source code must retain the above copyright notice, this +' list of conditions and the following disclaimer. +' +' - Redistributions in binary form must reproduce the above copyright notice, +' this list of conditions and the following disclaimer in the documentation +' and/or other materials provided with the distribution. +' +' - Neither the name of the Outercurve Foundation nor the names of its +' contributors may be used to endorse or promote products derived from this +' software without specific prior written permission. +' +' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +' WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +' ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +' ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Namespace WebsitePanel.Providers.Mail + + Public Class MailEnablePostoffice + Inherits MarshalByRefObject + + Private NameVal As String + Private StatusVal As Long + Private AccountVal As String + Private HostVal As String + + Private Structure IPOSTOFFICETYPE + Public Name As String + Public Status As Integer + Public Account As String + End Structure + + + Private Declare Function PostofficeGet Lib "MEAIPO.DLL" (ByRef lpPostoffice As IPOSTOFFICETYPE) As Integer + Private Declare Function PostofficeFindFirst Lib "MEAIPO.DLL" (ByRef lpPostoffice As IPOSTOFFICETYPE) As Integer + Private Declare Function PostofficeFindNext Lib "MEAIPO.DLL" (ByRef lpPostoffice As IPOSTOFFICETYPE) As Integer + Private Declare Function PostofficeAdd Lib "MEAIPO.DLL" (ByRef lpPostoffice As IPOSTOFFICETYPE) As Integer + Private Declare Function PostofficeEdit Lib "MEAIPO.DLL" (ByRef TargetPostoffice As IPOSTOFFICETYPE, ByRef NewPostoffice As IPOSTOFFICETYPE) As Integer + Private Declare Function PostofficeRemove Lib "MEAIPO.DLL" (ByRef lpPostoffice As IPOSTOFFICETYPE) As Integer + Private Declare Function SetCurrentHost Lib "MEAIPO.DLL" (ByVal CurrentHost As String) As Integer + + Public Function SetHost() As Integer + SetHost = SetCurrentHost(Host) + End Function + + + Public Function FindFirstPostoffice() As Integer + Dim CPostoffice As IPOSTOFFICETYPE + CPostoffice.Account = Account + CPostoffice.Name = Name + CPostoffice.Status = Status + FindFirstPostoffice = PostofficeFindFirst(CPostoffice) + Account = CPostoffice.Account + Name = CPostoffice.Name + Status = CPostoffice.Status + End Function + Public Function FindNextPostoffice() As Integer + Dim CPostoffice As IPOSTOFFICETYPE + CPostoffice.Account = Account + CPostoffice.Name = Name + CPostoffice.Status = Status + FindNextPostoffice = PostofficeFindNext(CPostoffice) + Account = CPostoffice.Account + Name = CPostoffice.Name + Status = CPostoffice.Status + End Function + + Public Function AddPostoffice() As Integer + Dim CPostoffice As IPOSTOFFICETYPE + CPostoffice.Account = Account + CPostoffice.Name = Name + CPostoffice.Status = Status + AddPostoffice = PostofficeAdd(CPostoffice) + Account = CPostoffice.Account + Name = CPostoffice.Name + Status = CPostoffice.Status + End Function + + Public Function GetPostoffice() As Integer + Dim CPostoffice As IPOSTOFFICETYPE + CPostoffice.Account = Account + CPostoffice.Name = Name + CPostoffice.Status = Status + GetPostoffice = PostofficeGet(CPostoffice) + Account = CPostoffice.Account + Name = CPostoffice.Name + Status = CPostoffice.Status + End Function + Public Function RemovePostoffice() As Integer + Dim CPostoffice As IPOSTOFFICETYPE + CPostoffice.Account = Account + CPostoffice.Name = Name + CPostoffice.Status = Status + RemovePostoffice = PostofficeRemove(CPostoffice) + Account = CPostoffice.Account + Name = CPostoffice.Name + Status = CPostoffice.Status + End Function + + + Public Function EditPostoffice(ByVal NewName As String, ByVal NewStatus As Long, ByVal NewAccount As String) As Integer + + Dim CPostoffice As IPOSTOFFICETYPE + Dim CPostofficeData As IPOSTOFFICETYPE + + ' Get the Find Stuff Set up + CPostoffice.Account = Account + CPostoffice.Name = Name + CPostoffice.Status = Status + ' Get the Data Set up + CPostofficeData.Account = NewAccount + CPostofficeData.Name = NewName + CPostofficeData.Status = NewStatus + EditPostoffice = PostofficeEdit(CPostoffice, CPostofficeData) + Account = CPostoffice.Account + Name = CPostoffice.Name + Status = CPostoffice.Status + + End Function + + + Public Property Name() As String + Get + Return Me.NameVal + End Get + Set(ByVal value As String) + Me.NameVal = value + End Set + End Property + + Public Property Status() As Long + Get + Return Me.StatusVal + End Get + Set(ByVal value As Long) + Me.StatusVal = value + End Set + End Property + + Public Property Account() As String + Get + Return Me.AccountVal + End Get + Set(ByVal value As String) + Me.AccountVal = value + End Set + End Property + + Public Property Host() As String + Get + Return Me.HostVal + End Get + Set(ByVal value As String) + Me.HostVal = value + End Set + End Property + + End Class + +End Namespace diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/WebsitePanel.Providers.Mail.MailEnable.vbproj b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/WebsitePanel.Providers.Mail.MailEnable.vbproj index 0a3e858d..755a2804 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/WebsitePanel.Providers.Mail.MailEnable.vbproj +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.MailEnable/WebsitePanel.Providers.Mail.MailEnable.vbproj @@ -73,6 +73,17 @@ VersionInfo.vb + + + + + + + + + + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx index 2958c470..784aa888 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx @@ -1,7 +1,7 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MailEnable_EditDomain.ascx.cs" Inherits="WebsitePanel.Portal.ProviderControls.MailEnable_EditDomain" %> - + @@ -18,4 +18,24 @@ -
\ No newline at end of file + + + + + + + + + + + + + + +
+ +
Only smart host email from authenticated senders: + +
Smart host mail to: + + (enter IP address or domain name of destination)
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.cs index e3c0775a..7aa33557 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.cs @@ -39,6 +39,7 @@ using System.Web.UI.HtmlControls; using WebsitePanel.Providers.Mail; + namespace WebsitePanel.Portal.ProviderControls { public partial class MailEnable_EditDomain : WebsitePanelControlBase, IMailEditDomainControl @@ -50,13 +51,26 @@ namespace WebsitePanel.Portal.ProviderControls public void BindItem(MailDomain item) { BindMailboxes(item); + + chkDomainSmartHostEnabled.Checked = Convert.ToBoolean(item["MailEnable_SmartHostEnabled"]); + chkDomainSmartHostAuthSenders.Checked = Convert.ToBoolean(item["MailEnable_SmartHostAuth"]); + txtDestination.Text = item.RedirectionHosts; } public void SaveItem(MailDomain item) { - item.CatchAllAccount = ddlCatchAllAccount.SelectedValue; item.AbuseAccount = ddlAbuseAccount.SelectedValue; item.PostmasterAccount = ddlPostmasterAccount.SelectedValue; + + // if we have a smarthost we need to clear the catchall + if (chkDomainSmartHostEnabled.Checked) + item.CatchAllAccount= ""; + else + item.CatchAllAccount = ddlCatchAllAccount.SelectedValue; + + item["MailEnable_SmartHostEnabled"] = chkDomainSmartHostEnabled.Checked.ToString(); + item["MailEnable_SmartHostAuth"] = chkDomainSmartHostAuthSenders.Checked.ToString(); + item.RedirectionHosts = txtDestination.Text; } private void BindMailboxes(MailDomain item) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.designer.cs index 53d48312..32593262 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/MailEnable_EditDomain.ascx.designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3074 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -66,5 +65,41 @@ namespace WebsitePanel.Portal.ProviderControls { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.DropDownList ddlAbuseAccount; + + /// + /// lblDomainSmartHostEnabled control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblDomainSmartHostEnabled; + + /// + /// chkDomainSmartHostEnabled control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox chkDomainSmartHostEnabled; + + /// + /// chkDomainSmartHostAuthSenders control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox chkDomainSmartHostAuthSenders; + + /// + /// txtDestination control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtDestination; } }