/// <summary>
        /// Reads response elements from XML.
        /// </summary>
        /// <param name="reader">The reader.</param>
        internal override void ReadElementsFromXml(EwsServiceXmlReader reader)
        {
            this.Rooms.Clear();
            base.ReadElementsFromXml(reader);

            reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.Rooms);

            if (!reader.IsEmptyElement)
            {
                // Because we don't have an element for count of returned object,
                // we have to test the element to determine if it is StartElement of return object or EndElement
                reader.Read();
                while (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Room))
                {
                    reader.Read(); // skip the start <Room>

                    EmailAddress emailAddress = new EmailAddress();
                    emailAddress.LoadFromXml(reader, XmlElementNames.RoomId);
                    this.Rooms.Add(emailAddress);

                    reader.ReadEndElement(XmlNamespace.Types, XmlElementNames.Room);
                    reader.Read();
                }

                reader.EnsureCurrentNodeIsEndElement(XmlNamespace.Messages, XmlElementNames.Rooms);
            }
        }
        /// <inheritdoc cref="IMailboxValidator.ValidateSynchronization"/>
        public CredentialsValidationInfo ValidateSynchronization(Mailbox mailbox)
        {
            var answer = new CredentialsValidationInfo()
            {
                IsValid = true
            };
            var credentials = mailbox.ConvertToSynchronizationCredentials(UserConnection);

            ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
            _ignoreSslWarnings = (bool)Terrasoft.Core.Configuration.SysSettings.GetValue(UserConnection, "IgnoreExchangeSSLWarnings");
            try {
                var service = _exchangeUtility.CreateExchangeService(UserConnection, credentials,
                                                                     credentials.SenderEmailAddress);
                Exchange.NameResolutionCollection resolutions = service.ResolveName(credentials.SenderEmailAddress);
                var mailboxName = string.Empty;
                if (resolutions.Any())
                {
                    Exchange.EmailAddress mailboxAddress = resolutions.First().Mailbox;
                    mailboxName = mailboxAddress.Name;
                }
                answer.Data = JsonConvert.SerializeObject(new {
                    MailboxName = mailboxName
                });
            } catch (Exception exception) {
                answer.IsValid = false;
                answer.Message = ConnectToServerCaption + exception.Message;
            } finally {
                ServicePointManager.ServerCertificateValidationCallback -= ValidateRemoteCertificate;
            }
            return(answer);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UnpinTeamMailboxRequest"/> class.
        /// </summary>
        /// <param name="service">The service</param>
        /// <param name="emailAddress">TeamMailbox email address</param>
        public UnpinTeamMailboxRequest(ExchangeService service, EmailAddress emailAddress)
            : base(service)
        {
            if (emailAddress == null)
            {
                throw new ArgumentNullException("emailAddress");
            }

            this.emailAddress = emailAddress;
        }
Esempio n. 4
0
 protected override bool ContainsValue(Exchange.EmailAddressKey typeKey)
 {
     Exchange.EmailAddress emailAddress = ExchangeUtility.SafeGetValue <Exchange.EmailAddressKey,
                                                                        Exchange.EmailAddressEntry, Exchange.EmailAddress>(DetailItems, typeKey);
     if (emailAddress == null)
     {
         return(false);
     }
     return(!string.IsNullOrEmpty(emailAddress.Address));
 }
Esempio n. 5
0
 protected override void SetLocalItemValue(Entity detailItem, Exchange.EmailAddressKey typeKey)
 {
     Exchange.EmailAddress emailAddress = ExchangeUtility.SafeGetValue <Exchange.EmailAddressKey,
                                                                        Exchange.EmailAddressEntry, Exchange.EmailAddress>(DetailItems, typeKey);
     if (emailAddress == null)
     {
         return;
     }
     detailItem.SetColumnValue("Number", emailAddress.Address);
     detailItem.SetColumnValue(DetailItemTypeColumnName, TypesMap[typeKey]);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SetTeamMailboxRequest"/> class.
        /// </summary>
        /// <param name="service">The service</param>
        /// <param name="emailAddress">TeamMailbox email address</param>
        /// <param name="sharePointSiteUrl">SharePoint site URL</param>
        /// <param name="state">TeamMailbox state</param>
        internal SetTeamMailboxRequest(ExchangeService service, EmailAddress emailAddress, Uri sharePointSiteUrl, TeamMailboxLifecycleState state)
            : base(service)
        {
            if (emailAddress == null)
            {
                throw new ArgumentNullException("emailAddress");
            }

            if (sharePointSiteUrl == null)
            {
                throw new ArgumentNullException("sharePointSiteUrl");
            }

            this.emailAddress = emailAddress;
            this.sharePointSiteUrl = sharePointSiteUrl;
            this.state = state;
        }
Esempio n. 7
0
        public static void DoAutodiscover(Microsoft.Exchange.WebServices.Data.EmailAddress emailAddress)
        {
            //EWSEditor.Common.EwsEditorAppSettings oSettings = new EWSEditor.Common.EwsEditorAppSettings();

            ExchangeService service = CreateExchangeService();

    //
    // Your code here


            //service.EnableScpLookup = GlobalSettings.EnableScpLookups;
            string sError = string.Empty;

            try
            { 
                service.AutodiscoverUrl(emailAddress.Address, ValidationCallbackHelper.RedirectionUrlValidationCallback);
                EwsUrl = service.Url;
            }
            catch (AutodiscoverLocalException oException)
            {
                sError += string.Format("Error: {0}\r\n", oException.HResult);
                sError += oException.ToString();
                ErrorDialog.ShowError(sError);
            }
            catch (System.IO.IOException oIOException)
            {
                sError += string.Format("Error: {0}\r\n", oIOException.HResult);
                sError = oIOException.ToString();
                ErrorDialog.ShowError(sError);
            }
            catch (ServerBusyException srBusyException)  // 2013+
            {
                Console.WriteLine(srBusyException);
                sError += string.Format("Error: {0}\r\n", srBusyException.HResult);
                sError += "    BackOffMilliseconds: " + srBusyException.BackOffMilliseconds.ToString() + "\r\n";
                sError += "    Error Message: " + srBusyException.Message + "\r\n";
                sError += "    Inner Error Message: " + srBusyException.InnerException + "\r\n";
                sError += "    Stack Trace: " + srBusyException.StackTrace + "\r\n";
                sError += "    See: " + srBusyException.HelpLink + "\r\n";
            }

 
 
        }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Attendee"/> class from an EmailAddress.
 /// </summary>
 /// <param name="mailbox">The mailbox used to initialize the Attendee.</param>
 public Attendee(EmailAddress mailbox)
     : base(mailbox)
 {
 }
        /// <summary>
        /// Convert the SMS recipient list from MobilePhone collection type to EmailAddressCollection type.
        /// </summary>
        /// <param name="recipientCollection">Recipient list in a MobilePhone collection type.</param>
        /// <returns>An EmailAddressCollection object containing recipients with "MOBILE" address type. </returns>
        private static EmailAddressCollection ConvertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection(Collection<MobilePhone> recipientCollection)
        {
            EmailAddressCollection emailCollection = new EmailAddressCollection(XmlElementNames.Address);
            foreach (MobilePhone recipient in recipientCollection)
            {
                EmailAddress emailAddress = new EmailAddress(
                    recipient.Name, 
                    recipient.PhoneNumber, 
                    RuleActions.MobileType);
                emailCollection.Add(emailAddress);
            }

            return emailCollection;
        }
Esempio n. 10
0
		private bool FilterActive(EmailAddress emailAddress)
		{
			if (LocationFilter == null)
				return true;

			return LocationFilter.Contains(emailAddress.Address);
		}
Esempio n. 11
0
		private IEnumerable<EmailAddress> LoadRooms(EmailAddress emailAddress)
		{
			return _service.GetRooms(emailAddress);
		}
Esempio n. 12
0
 public EmailAddress(EWS.EmailAddress address)
 {
     _address = address;
 }
        private static Folder GetSourceFolder(ExchangeService service, EmailAddress email)
        {
            log4net.Config.XmlConfigurator.Configure();

            // Use the following search filter to get all mail in the Inbox with the word "extended" in the subject line.
            SearchFilter searchCriteria = new SearchFilter.SearchFilterCollection(LogicalOperator.And,
                //Search for Folder DisplayName that matches mailbox email address:
                new SearchFilter.IsEqualTo(FolderSchema.DisplayName, email.Address));

            // Find the search folder named "MailModder".
            FindFoldersResults findResults = service.FindFolders(
                WellKnownFolderName.Inbox,
                searchCriteria,
                new FolderView(50));

            //Return root of inbox by default:
            Folder returnFolder = Folder.Bind(service, WellKnownFolderName.Inbox);
            foreach (Folder searchFolder in findResults.Folders)
            {
                if (searchFolder.DisplayName == email.Address)
                {
                    returnFolder = searchFolder;
                }
            }

            return returnFolder;
        }
        public ActionResult MessageEWS(EmailAddress email)
        {
            ExchangeService service = Connection.ConnectEWS();

            //Create empty list for all mailbox messages:
            var listing = new List<EmailMessage>();

            //Create ItemView with correct pagesize and offset:
            ItemView view = new ItemView(Connection.ExPageSize, Connection.ExOffset, OffsetBasePoint.Beginning);

            view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties,
                EmailMessageSchema.Subject,
                EmailMessageSchema.DateTimeReceived,
                EmailMessageSchema.From,
                EmailMessageSchema.ToRecipients);

            view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);

            //string sf = "Body:\"Compensation\"";

            //Define the new PidTagParentDisplay property to use for filtering:
            ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(0x0E05, MapiPropertyType.String);
            SearchFilter searchCriteria = new SearchFilter.IsEqualTo(def, email.Address);
            FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchCriteria, view);

            foreach (EmailMessage it in findResults.Items)
            {
                listing.Add(it);
            }

            return View(listing.ToList<EmailMessage>());
        }
        /// <summary>
        ///     Expands the distribution list into a set of user emails.
        /// </summary>
        private void TryExpandDistributionList(EmailAddress address)
        {
            if (Members == null)
            {
                Members = new ObservableCollection<string>();
            }

            if (address.MailboxType == MailboxType.PublicGroup)
            {
                var groupResults = Service.ExpandGroup(address);

                foreach (var email in groupResults)
                {
                    LoggingViewModel.Instance.Logger.Write(string.Concat("TryExpanDistributionList ", email));
                    TryExpandDistributionList(email);
                }
            }
            else
            {
                if (!Members.Contains(address.Address))
                {
                    Members.Add(address.Address);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EmailAddressEntry"/> class.
 /// </summary>
 internal EmailAddressEntry()
     : base()
 {
     this.emailAddress           = new EmailAddress();
     this.emailAddress.OnChange += this.EmailAddressChanged;
 }
Esempio n. 17
0
        private static void SendEmailWithReport(ExchangeService service, string recipient)
        {
            EmailMessage email = new EmailMessage(service);
            EmailAddress to = new EmailAddress();
            MessageBody body = new MessageBody();
            body.BodyType = BodyType.HTML;
            body.Text = "sample body.";
            var subject = "Sample subject " + DateTime.Now;

            to.Address = recipient;
            email.ToRecipients.Add(to);
            email.Subject = subject;

            email.Body = body + "\r\n" + File.ReadAllText(@"C:\sample.html");

            email.Send();
        }