Beispiel #1
0
 private void OutlookTfsConnectorRibbon_Load(object sender, RibbonUIEventArgs e)
 {
     outlookApp   = Globals.ThisAddIn.Application as Microsoft.Office.Interop.Outlook.Application;
     outlookAddin = Globals.ThisAddIn;
     //btnAddEmailToTfs.Enabled = outlookAddin.EnableAddinFunctions;
     //tabNewMailMessage.Ribbon =
 }
        public TfsWorkItemUserForm(Microsoft.Office.Interop.Outlook.MailItem outlookCurrentMailItem, ThisAddIn thisAddIn, ExchangeUser exchangeUser)
        {
            _outlookCurrentMailItem = outlookCurrentMailItem;
            _thisAddIn    = thisAddIn;
            _exchangeUser = exchangeUser;
            InitializeComponent();
            this.CenterToScreen();
            btnSaveNClose.Enabled = false;
            btnSave.Enabled       = false;

            txtTitle.Text = _outlookCurrentMailItem.Subject;

            cbProject.DataSource    = Globals.ThisAddIn.Settings.TfsConfigurations;
            cbProject.DisplayMember = "TfsProject";

            this.LoadOptions();

            txtTitle.Text = _outlookCurrentMailItem.Subject;

            var newLine = "<br/>" + Environment.NewLine;

            StringBuilder bodyText = new StringBuilder();

            bodyText.Append("From : " + (_outlookCurrentMailItem.SenderName ?? "") +
                            " (" + (GetSenderEmailAddress(_outlookCurrentMailItem.Sender) ?? _outlookCurrentMailItem.SenderEmailAddress) + ")" +
                            newLine);
            bodyText.Append("To : " + (_outlookCurrentMailItem.To ?? "") + newLine);
            if (!string.IsNullOrEmpty(_outlookCurrentMailItem.CC))
            {
                bodyText.Append("CC : " + (_outlookCurrentMailItem.CC ?? "") + newLine);
            }
            if (!string.IsNullOrEmpty(_outlookCurrentMailItem.BCC))
            {
                bodyText.Append("BCC : " + (_outlookCurrentMailItem.BCC ?? "") + newLine);
            }
            if (!string.IsNullOrEmpty(_outlookCurrentMailItem.Subject))
            {
                bodyText.Append("Subject : " + (_outlookCurrentMailItem.Subject ?? "") + newLine);
            }
            bodyText.Append("Sent : " + _outlookCurrentMailItem.SentOn + newLine);

            bodyText.Append("-----------------------------------------" + newLine);
            bodyText.Append(_outlookCurrentMailItem.Body.Replace(Environment.NewLine, newLine));


            txtBody.Text = bodyText.ToString();

            lblAttachements.Text = lblAttachements.Text + _outlookCurrentMailItem.Attachments.Count;


            chkLstBoxAttachements.Items.Add("<MSG>, size:" + _outlookCurrentMailItem.Size / 1024 + "K", true);
            for (int i = 1; i <= _outlookCurrentMailItem.Attachments.Count; i++)
            {
                chkLstBoxAttachements.Items.Add(
                    string.Format("{0}, size:{1}K",
                                  _outlookCurrentMailItem.Attachments[i].GetFileName(),
                                  _outlookCurrentMailItem.Attachments[i].Size / 1024),
                    false);
            }

            // check if the subject can parse the regex
            if (!string.IsNullOrEmpty(Globals.ThisAddIn.Settings.RegexToParseEmailSubjects))
            {
                Regex regex = new Regex(Globals.ThisAddIn.Settings.RegexToParseEmailSubjects);
                var   match = regex.Match(_outlookCurrentMailItem.Subject);
                if (match.Success)
                {
                    var   value  = match.Value;
                    Regex regex2 = new Regex("[\\d]+");
                    var   match2 = regex2.Match(value);
                    if (match2.Success)
                    {
                        tabControl1.SelectedIndex = 1;
                        txtExistingItemId.Text    = match2.Value;
                    }
                }
            }
            FindWorkItem(txtExistingItemId.Text, out existingItem, out existingItemValidated);
        }