Esempio n. 1
0
        private void AddAddress(MessagesAddress address)
        {
            int ret = Interop.Messages.AddAddress(_messageHandle, address.Number, (int)address.Type);

            if (ret != (int)MessagesError.None)
            {
                Log.Error(Globals.LogTag, "Failed to add address, Error - " + (MessagesError)ret);
                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
            }
        }
Esempio n. 2
0
        private void GetAllAddresses()
        {
            int count;

            int ret = Interop.Messages.GetAddressCount(_messageHandle, out count);

            if (ret != (int)MessagesError.None)
            {
                Log.Error(Globals.LogTag, "Failed to get address count, Error - " + (MessagesError)ret);
                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
            }

            string number;
            int    type;
            var    To   = new Collection <MessagesAddress>();
            var    Cc   = new Collection <MessagesAddress>();
            var    Bcc  = new Collection <MessagesAddress>();
            var    From = new Collection <MessagesAddress>();

            for (int i = 0; i < count; i++)
            {
                ret = Interop.Messages.GetAddress(_messageHandle, i, out number, out type);
                if (ret != (int)MessagesError.None)
                {
                    Log.Error(Globals.LogTag, "Failed to get address, Error - " + (MessagesError)ret);
                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
                }

                var addressItem = new MessagesAddress((RecipientType)type, number);
                switch ((RecipientType)type)
                {
                case RecipientType.To:
                    To.Add(addressItem);
                    break;

                case RecipientType.Cc:
                    Cc.Add(addressItem);
                    break;

                case RecipientType.Bcc:
                    Bcc.Add(addressItem);
                    break;

                default:
                    From.Add(addressItem);
                    break;
                }
            }

            _to   = To;
            _cc   = Cc;
            _bcc  = Bcc;
            _from = From;
        }