當前位置: 首頁>>代碼示例>>C#>>正文


C# Mail.MailAlias類代碼示例

本文整理匯總了C#中WebsitePanel.Providers.Mail.MailAlias的典型用法代碼示例。如果您正苦於以下問題:C# MailAlias類的具體用法?C# MailAlias怎麽用?C# MailAlias使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MailAlias類屬於WebsitePanel.Providers.Mail命名空間,在下文中一共展示了MailAlias類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateMailForwarding

        public static int UpdateMailForwarding(MailAlias item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load original meta item
            MailAlias origItem = (MailAlias)PackageController.GetPackageItem(item.Id);
            if (origItem == null)
                return BusinessErrorCodes.ERROR_MAIL_FORWARDINGS_PACKAGE_ITEM_NOT_FOUND;

            // check package
            int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // place log record
            TaskManager.StartTask("MAIL_FORWARDING", "UPDATE", origItem.Name);
            TaskManager.ItemId = item.Id;

            try
            {
                // update forwarding
                MailServer mail = new MailServer();
                ServiceProviderProxy.Init(mail, origItem.ServiceId);
                MailAlias alias = new MailAlias();
                alias.Name = origItem.Name;
                alias.ForwardTo = item.ForwardTo;

                //For MailEnable alias updating
                alias.DeleteOnForward = true;
                alias.ForwardingAddresses = new string[1];
                alias.ForwardingAddresses[0] = item.ForwardTo;
               
                //
                
                // update service item
                mail.UpdateMailAlias(alias);
                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
開發者ID:jordan49,項目名稱:websitepanel,代碼行數:48,代碼來源:MailServerController.cs

示例2: AddMailForwarding

 public int AddMailForwarding(MailAlias item)
 {
     return MailServerController.AddMailForwarding(item);
 }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:4,代碼來源:esMailServers.asmx.cs

示例3: AddMailForwarding

        public static int AddMailForwarding(MailAlias item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // check package
            int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // check quota
            QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.MAIL_FORWARDINGS);
            if (quota.QuotaExhausted)
                return BusinessErrorCodes.ERROR_MAIL_FORWARDINGS_RESOURCE_QUOTA_LIMIT;

            // check if mail resource is available
            int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Mail);
            if (serviceId == 0)
                return BusinessErrorCodes.ERROR_MAIL_RESOURCE_UNAVAILABLE;

            // check package items
            if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(MailAlias)) != null)
                return BusinessErrorCodes.ERROR_MAIL_FORWARDINGS_PACKAGE_ITEM_EXISTS;

            // place log record
            TaskManager.StartTask("MAIL_FORWARDING", "ADD", item.Name);

            try
            {
                // check service items
                MailServer mail = new MailServer();
                ServiceProviderProxy.Init(mail, serviceId);
                if (mail.MailAliasExists(item.Name))
                    return BusinessErrorCodes.ERROR_MAIL_FORWARDINGS_SERVICE_ITEM_EXISTS;

                // add domain if not exists
                string domainName = item.Name.Substring(item.Name.IndexOf("@") + 1);
                int domainResult = AddMailDomain(item.PackageId, serviceId, domainName);
                if (domainResult < 0)
                    return domainResult;

                // create service item
                MailAlias alias = new MailAlias();
                alias.Name = item.Name;
                alias.ForwardTo = item.ForwardTo;
                //for MailEnable alias creation
                alias.DeleteOnForward = true;
                alias.ForwardingAddresses = new string[1];
                alias.ForwardingAddresses[0] = item.ForwardTo;
                alias.Password = Guid.NewGuid().ToString("N").Substring(0, 12);
                alias.Enabled = true;
				
                // add service item
                mail.CreateMailAlias(alias);

                // save item
                item.ServiceId = serviceId;
                int itemId = PackageController.AddPackageItem(item);

                TaskManager.ItemId = itemId;

                return itemId;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
開發者ID:jordan49,項目名稱:websitepanel,代碼行數:72,代碼來源:MailServerController.cs

示例4: SaveItem

        private void SaveItem()
        {
            if (!Page.IsValid)
                return;

            // get form data
            MailAlias item = new MailAlias();
            item.Id = PanelRequest.ItemID;
            item.PackageId = PanelSecurity.PackageId;
            item.Name = emailAddress.Email;
            item.ForwardTo = txtForwardTo.Text.Trim();

            //checking if forwarding name is different from existing e-mail accounts
            MailAccount[] accounts = ES.Services.MailServers.GetMailAccounts(PanelSecurity.PackageId, true);
            foreach (MailAccount account in accounts)
            {
                if (item.Name == account.Name)
                {
                    ShowWarningMessage("MAIL_FORW_NAME");
                    return;
                }
            }

            //checking if forwarding name is different from existing e-mail lists
            MailList[] lists = ES.Services.MailServers.GetMailLists(PanelSecurity.PackageId, true);
            foreach (MailList list in lists)
            {
                if (item.Name == list.Name)
                {
                    ShowWarningMessage("MAIL_FORW_NAME");
                    return;
                }
            }

            //checking if forwarding name is different from existing e-mail groups
            MailGroup[] mailgroups = ES.Services.MailServers.GetMailGroups(PanelSecurity.PackageId, true);
            foreach (MailGroup group in mailgroups)
            {
                if (item.Name == group.Name)
                {
                    ShowWarningMessage("MAIL_FORW_NAME");
                    return;
                }
            }

            // get other props
            IMailEditForwardingControl ctrl = (IMailEditForwardingControl)providerControl.Controls[0];
            ctrl.SaveItem(item);

            if (PanelRequest.ItemID == 0)
            {
                // new item
                try
                {
                    int result = ES.Services.MailServers.AddMailForwarding(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }

                }
                catch (Exception ex)
                {
                    ShowErrorMessage("MAIL_ADD_FORWARDING", ex);
                    return;
                }
            }
            else
            {
                // existing item
                try
                {
                    int result = ES.Services.MailServers.UpdateMailForwarding(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("MAIL_UPDATE_FORWARDING", ex);
                    return;
                }
            }

            // return
            RedirectSpaceHomePage();
        }
開發者ID:jordan49,項目名稱:websitepanel,代碼行數:90,代碼來源:MailForwardingsEditForwarding.ascx.cs

示例5: BindItem

        public void BindItem(MailAlias item)
        {

        }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:4,代碼來源:IceWarp_EditForwarding.ascx.cs

示例6: GetMailAliases

		public MailAlias[] GetMailAliases(string domainName)
		{
			try
			{

				svcAliasAdmin aliases = new svcAliasAdmin();
				PrepareProxy(aliases);

				AliasInfoListResult result = aliases.GetAliases(AdminUsername, AdminPassword, domainName);

				if (!result.Result)
					throw new Exception(result.Message);

				List<MailAlias> aliasesList = new List<MailAlias>();


				foreach (AliasInfo alias in result.AliasInfos)
				{
					if (alias.Addresses.Length == 1)
					{
						MailAlias mailAlias = new MailAlias();
						mailAlias.Name = alias.Name + "@" + domainName;
						mailAlias.ForwardTo = alias.Addresses[0];
						aliasesList.Add(mailAlias);
					}
				}
				return aliasesList.ToArray();
			}
			catch (Exception ex)
			{
				throw new Exception("Could not get the list of mail aliases", ex);
			}


		}
開發者ID:jordan49,項目名稱:websitepanel,代碼行數:35,代碼來源:SmarterMail7.cs

示例7: CreateMailAlias

		public void CreateMailAlias(MailAlias mailAlias)
		{
			try
			{
				svcAliasAdmin aliases = new svcAliasAdmin();
				PrepareProxy(aliases);

				GenericResult result = aliases.AddAlias(AdminUsername, AdminPassword,
														GetDomainName(mailAlias.Name), mailAlias.Name,
														new string[] { mailAlias.ForwardTo });


				if (!result.Result)
					throw new Exception(result.Message);
			}

			catch (Exception ex)
			{
				if (MailAliasExists(mailAlias.Name))
				{
					DeleteMailAlias(mailAlias.Name);
				}
				Log.WriteError(ex);
				throw new Exception("Could not create mail alias", ex);

			}

		}
開發者ID:jordan49,項目名稱:websitepanel,代碼行數:28,代碼來源:SmarterMail7.cs

示例8: UpdateMailForwardingAsync

 /// <remarks/>
 public void UpdateMailForwardingAsync(MailAlias item)
 {
     this.UpdateMailForwardingAsync(item, null);
 }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:5,代碼來源:MailServersProxy.cs

示例9: CreateMailAliasAsync

 /// <remarks/>
 public void CreateMailAliasAsync(MailAlias mailAlias)
 {
     this.CreateMailAliasAsync(mailAlias, null);
 }
開發者ID:jordan49,項目名稱:websitepanel,代碼行數:5,代碼來源:MailServerProxy.cs

示例10: UpdateMailForwarding

 public int UpdateMailForwarding(MailAlias item)
 {
     object[] results = this.Invoke("UpdateMailForwarding", new object[] {
                 item});
     return ((int)(results[0]));
 }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:6,代碼來源:MailServersProxy.cs

示例11: BeginUpdateMailForwarding

 /// <remarks/>
 public System.IAsyncResult BeginUpdateMailForwarding(MailAlias item, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateMailForwarding", new object[] {
                 item}, callback, asyncState);
 }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:6,代碼來源:MailServersProxy.cs

示例12: AddMailForwardingAsync

 /// <remarks/>
 public void AddMailForwardingAsync(MailAlias item, object userState)
 {
     if ((this.AddMailForwardingOperationCompleted == null))
     {
         this.AddMailForwardingOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddMailForwardingOperationCompleted);
     }
     this.InvokeAsync("AddMailForwarding", new object[] {
                 item}, this.AddMailForwardingOperationCompleted, userState);
 }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:10,代碼來源:MailServersProxy.cs

示例13: UpdateMailForwarding

 public int UpdateMailForwarding(MailAlias item)
 {
     return MailServerController.UpdateMailForwarding(item);
 }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:4,代碼來源:esMailServers.asmx.cs

示例14: GetMailAlias

		public MailAlias GetMailAlias(string mailAliasName)
		{
			svcAliasAdmin aliases = new svcAliasAdmin();
			PrepareProxy(aliases);


			MailAlias alias = new MailAlias();
			MailAlias newAlias = new MailAlias();

			//convert old alliases created as mailboxes
			if (!MailAliasExists(mailAliasName))
			{
				MailAccount account = GetAccount(mailAliasName);
				newAlias.Name = account.Name;
				if ((account.ForwardingAddresses != null) && (account.ForwardingAddresses.Length > 0))
				{
					newAlias.ForwardTo = account.ForwardingAddresses[0];
				}
				else
				{
					newAlias.ForwardTo = string.Empty;
				}
				DeleteAccount(mailAliasName);
				CreateMailAlias(newAlias);
				return newAlias;
			}

			AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName);
			alias.Name = result.AliasInfo.Name;
			if ((result.AliasInfo.Addresses != null) && (result.AliasInfo.Addresses.Length > 0))
			{
				alias.ForwardTo = result.AliasInfo.Addresses[0];
			}
			else
			{
				alias.ForwardTo = "[email protected]";
			}
			return alias;
		}
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:39,代碼來源:SmarterMail10.cs

示例15: UpdateMailAlias

 public void UpdateMailAlias(MailAlias mailAlias)
 {
     this.Invoke("UpdateMailAlias", new object[] {
                 mailAlias});
 }
開發者ID:jordan49,項目名稱:websitepanel,代碼行數:5,代碼來源:MailServerProxy.cs


注:本文中的WebsitePanel.Providers.Mail.MailAlias類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。