private UpdateResultEnum AddToMailrelay(DynamicsCrmConnection dynamicsCrmConnection, MailrelayInformation mailrelayInformation, int groupId)
        {
            if (mailrelayInformation.new_mailrelaysubscriberid != null)
            {
                return(UpdateResultEnum.AlreadyUpToDate);
            }

            Subscriber subscriber = new Subscriber(_mailrelayConnection);

            try
            {
                getSubscribersReply reply = subscriber.GetMailrelaySubscribers(mailrelayInformation.emailaddress1);

                if (reply == null)
                {
                    mailrelayInformation.new_mailrelaysubscriberid = subscriber.AddNewSubscriber(mailrelayInformation.fullname, mailrelayInformation.emailaddress1, new List <int>()
                    {
                        groupId
                    }, mailrelayInformation.GetCustomFields());
                }
                else
                {
                    reply.groups.Add(groupId.ToString());

                    subscriber.UpdateFromReply(reply);

                    mailrelayInformation.new_mailrelaysubscriberid = int.Parse(reply.id);
                }
            }
            catch (Exception exception)
            {
                Log.Write(Connection, exception.Message, typeof(ExportContactToMailrelay), exception.StackTrace, DataLayer.MongoData.Config.LogLevelEnum.OptionError);
                return(UpdateResultEnum.Failed);
            }

            mailrelayInformation.UpdateContactMailrelaySubscriberid(dynamicsCrmConnection);

            return(UpdateResultEnum.Updated);
        }