Exemplo n.º 1
0
        /// <summary>
        /// Handles clicks on the AppBars
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource == AppBarButtonForwardMail)
            {
                MailHandler.ForwardFlag = true;
                MailHandler.Message     = CurrentMessage;
                Frame.Navigate(typeof(CreateMailPage));
            }
            else if (e.OriginalSource == AppBarButtonReplyMail)
            {
                MailHandler.ReplyFlag = true;
                MailHandler.Message   = CurrentMessage;
                Frame.Navigate(typeof(CreateMailPage));
            }
            else if (e.OriginalSource == AppBarButtonDeleteMail)
            {
                bool userChoosedDelete = await DisplayDeleteDialog();

                if (userChoosedDelete)
                {
                    bool success = MailHandler.DeleteMessage(CurrentMessage);

                    if (success)
                    {
                        RefreshMail();
                    }
                }
            }
            else if (e.OriginalSource == AppBarButtonRefreshMail)
            {
                RefreshMail();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates mail data
        /// </summary>
        public void RefreshMail()
        {
            if (AttachedFileList != null)
            {
                AttachedFileList.Clear();
            }

            ObservableCollection <MailHeader> tempMailList = MailHandler.GetMailHeaders(asb.Text);

            //If no mail was found on server, display error dialog
            if (tempMailList == null)
            {
                DisplayErrorDialog("Mail error", "No mail found. Try again!");
            }
            //If mail was found, replace MailHeaderList with the list with new mail and update UI
            else
            {
                if (MailHeaderList != null)
                {
                    MailHeaderList.Clear();
                }

                MailHeaderList = tempMailList;

                Bindings.Update();              //Updates the ListView data

                CurrentMessage             = MailHandler.GetSpecificMail(MailHeaderList[0].UniqueId);
                MailListView.SelectedIndex = 0;
                HandleAttachmentsAsync(CurrentMessage);
                SetContent(CurrentMessage);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles sending mail
        /// </summary>
        private void HandleSendingMail()
        {
            if (To.Text.Equals(""))
            {
                DisplayDialog("Missing information", "To field empty.");
                To.Focus(FocusState.Programmatic);
                return;
            }

            bool success;

            //If the message is a reply message or a forwarded message
            if (MailHandler.ReplyFlag == true || MailHandler.ForwardFlag == true)
            {
                success = MailHandler.SendMail(MailHandler.Message, From.Text, To.Text, Cc.Text, Bcc.Text, Subject.Text, Message.Text);
            }
            //Standard email send
            else
            {
                success = MailHandler.SendMail(null, From.Text, To.Text, Cc.Text, Bcc.Text, Subject.Text, Message.Text);
            }

            if (success)
            {
                DisplayDialog("Mail sent", "Mail was sent successfully!");
            }
            else
            {
                DisplayDialog("Send failed", "Mail failed to send. Try again!");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Inits the UI
        /// </summary>
        private void InitUi()
        {
            From.Text = MailHandler.UserEmail;

            //If the user has clicked Reply
            if (MailHandler.ReplyFlag == true)
            {
                if (MailHandler.Message != null)
                {
                    MailHandler.Message = MailHandler.CreateReply(MailHandler.Message);
                }

                var message = MailHandler.Message;

                //Adds From text
                List <MailboxAddress> tempList = message.From.Mailboxes.ToList();
                From.Text = tempList[0].Address;

                //Adds To text
                string tempTo     = message.To.ToString();
                int    startIndex = tempTo.IndexOf('<');
                int    endIndex   = tempTo.LastIndexOf('>');
                int    length     = endIndex - startIndex - 1;

                //If '<' and '>' was found, set the email address to the To textbox without those characters,
                //otherwise just set the To textbox
                if (startIndex != -1 || length != -1)
                {
                    //email==string between "<" and ">" only
                    string email = tempTo.Substring(startIndex + 1, length);
                    To.Text = email;
                }
                else
                {
                    To.Text = tempTo;
                }

                Subject.Text = message.Subject;

                Message.Text = message.TextBody;
            }

            //If the user has clicked Forward
            if (MailHandler.ForwardFlag == true)
            {
                if (MailHandler.Message != null)
                {
                    MailHandler.Message = MailHandler.CreateForward(MailHandler.Message);
                }

                var message = MailHandler.Message;

                Subject.Text = message.Subject;

                Message.Text = message.TextBody;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles event when user clicks the listview - sets the clicked mail´s content to the webview&listview
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MailListView_ItemClicked(object sender, ItemClickEventArgs e)
        {
            AttachedFileList.Clear();

            MailHeader msg = (MailHeader)e.ClickedItem;

            CurrentMessage = MailHandler.GetSpecificMail(msg.UniqueId);
            HandleAttachmentsAsync(CurrentMessage);
            SetContent(CurrentMessage);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Logs in to mail server, gets mail summaries (headers) and sets the first mail´s content to the
        /// webview and listview (attachments)
        /// </summary>
        /// <returns></returns>
        public bool HandleMail()
        {
            MailHandler.Login();

            ObservableCollection <MailHeader> tempMailList = MailHandler.GetMailHeaders(null);

            if (tempMailList == null)
            {
                return(false);
            }
            else
            {
                MailHeaderList = tempMailList;

                Bindings.Update();

                CurrentMessage             = MailHandler.GetSpecificMail(MailHeaderList[0].UniqueId);
                MailListView.SelectedIndex = 0;
                HandleAttachmentsAsync(CurrentMessage);
                SetContent(CurrentMessage);
            }

            return(true);
        }