Ejemplo n.º 1
0
        private void comboEmailFrom_SelectionChangeCommitted(object sender, EventArgs e)
        {
            EmailAddress emailAddressSelected = _listEmailAddresses[comboEmailFrom.SelectedIndex];

            textFromAddress.Text = emailAddressSelected.GetFrom();
            if (!_isComposing || !_isSigningEnabled)
            {
                return;
            }
            SetSig(EmailMessages.GetCertFromPrivateStore(emailAddressSelected.EmailUsername));
        }
Ejemplo n.º 2
0
		private void LoadSig() {
			if(!_isComposing || !_isSigningEnabled) {
				return;
			}
			EmailAddress emailAddressDefault=EmailAddresses.GetByClinic(ClinicNum);
			if(emailAddressDefault!=null) {//Must have a default emailaddress to be allowed to set a signature/cert.  Presumably 
				EmailAddress emailAddressSelected=null;
				if(TryGetFromEmailAddress(out emailAddressSelected)==FromAddressMatchResult.Failed) {
					return;
				}
				SetSig(EmailMessages.GetCertFromPrivateStore(emailAddressSelected.EmailUsername));
			}
		}
Ejemplo n.º 3
0
		public EmailAddress PickEmailAccount() {
			FormEmailAddresses formEA=new FormEmailAddresses();
			formEA.IsSelectionMode=true;
			formEA.ShowDialog();
			if(formEA.DialogResult==DialogResult.OK) {
				EmailAddress emailAccountSelected=_listEmailAddresses.Find(x => x.EmailAddressNum==formEA.EmailAddressNum);
				if(emailAccountSelected!=null) {
					EmailAddressPreview=emailAccountSelected;
				}
				else {
					MsgBox.Show(this,"Error selecting email account.");
					return null;
				}
				textFromAddress.Text=EmailAddressPreview.GetFrom();
				if(!_isComposing || !_isSigningEnabled) {
					return null;
				}
				SetSig(EmailMessages.GetCertFromPrivateStore(emailAccountSelected.EmailUsername));
			}
			else {
				EmailAddressPreview=null;
			}
			return EmailAddressPreview;
		}
Ejemplo n.º 4
0
        private void FillComboEmail()
        {
            //emails to include:
            //1. Default Practice/Clinic
            //2. Me
            //3. All other email addresses not tied to a user
            _listEmailAddresses = new List <EmailAddress>();
            EmailAddress emailAddressDefault = EmailAddresses.GetByClinic(ClinicNum);
            EmailAddress emailAddressMe      = EmailAddresses.GetForUser(Security.CurUser.UserNum);

            if (emailAddressDefault != null)
            {
                _listEmailAddresses.Add(emailAddressDefault);
            }
            if (emailAddressMe != null)
            {
                _listEmailAddresses.Add(emailAddressMe);
            }
            foreach (EmailAddress emailCur in EmailAddresses.GetDeepCopy())
            {
                if ((emailAddressDefault != null && emailCur.EmailUsername == emailAddressDefault.EmailUsername) ||
                    (emailAddressMe != null && emailCur.EmailUsername == emailAddressMe.EmailUsername))
                {
                    continue;
                }
                _listEmailAddresses.Add(emailCur);
            }
            _listEmailAddresses.ForEach(x => {
                if (emailAddressDefault != null && x.EmailUsername == emailAddressDefault.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Practice/Clinic") + " <" + x.EmailUsername + ">");
                }
                else if (emailAddressMe != null && x.EmailUsername == emailAddressMe.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Me") + " <" + x.EmailUsername + ">");
                }
                else
                {
                    comboEmailFrom.Items.Add(x.EmailUsername);
                }
            });
            for (int i = 0; i < _listEmailAddresses.Count; i++)
            {
                //Sending email address should be set before loading this control.  This is the best approach to matching email account.
                if (EmailAddressPreview != null)
                {
                    if (_listEmailAddresses[i].EmailAddressNum == EmailAddressPreview.EmailAddressNum)
                    {
                        comboEmailFrom.SelectedIndex = i;
                        break;                        //Found the right emailaddress, no need to look further.
                    }
                }
                else                  //Less reliable, but works in most email account setups.
                {
                    string senderAddress = _listEmailAddresses[i].SenderAddress.Trim().ToLower();
                    string emailUserName = _listEmailAddresses[i].EmailUsername.Trim().ToLower();
                    string fromAddress   = _emailMessage.FromAddress.Trim().ToLower();
                    if ((senderAddress != "" && fromAddress.Contains(senderAddress)) ||
                        (emailUserName != "" && fromAddress.Contains(emailUserName)) ||
                        (fromAddress != "" && (emailUserName.Contains(fromAddress) || senderAddress.Contains(fromAddress))))
                    {
                        comboEmailFrom.SelectedIndex = i;
                        break;                        //Found an emailaddress that is probably right, best to stop here as opposed to finding another potential match.
                    }
                }
            }
            if (!_isComposing || !_isSigningEnabled)
            {
                return;
            }
            if (emailAddressDefault != null)
            {
                SetSig(EmailMessages.GetCertFromPrivateStore(GetOutgoingEmailAddress().EmailUsername));
            }
        }
Ejemplo n.º 5
0
 ///<summary>Loads the given emailMessage into the control.
 ///Set listEmailMessages to messages to be considered for the auto complete contacts pop up.  When null will query.</summary>
 public void LoadEmailMessage(EmailMessage emailMessage, List <EmailMessage> listHistoricEmailMessages = null)
 {
     Cursor        = Cursors.WaitCursor;
     _emailMessage = emailMessage;
     _patCur       = Patients.GetPat(_emailMessage.PatNum);           //we could just as easily pass this in.
     if (_emailMessage.SentOrReceived == EmailSentOrReceived.Neither) //Composing a message
     {
         _isComposing = true;
         if (_isSigningEnabled)
         {
             SetSig(EmailMessages.GetCertFromPrivateStore(_emailMessage.FromAddress));
         }
         _emailMessage.UserNum = Security.CurUser.UserNum; //UserNum is also updated when sent. Setting here to display when composing.
     }
     else                                                  //sent or received (not composing)
                                                           //For all email received or sent types, we disable most of the controls and put the window into a mostly read-only state.
                                                           //There is no reason a user should ever edit a received message.
                                                           //The user can copy the content and send a new email if needed (to mimic forwarding until we add the forwarding feature).
     {
         _isComposing              = false;
         textMsgDateTime.Text      = _emailMessage.MsgDateTime.ToString();
         textMsgDateTime.ForeColor = Color.Black;
         gridAttachments.SetAddButtonEnabled(false);
         textFromAddress.ReadOnly         = true;
         textToAddress.ReadOnly           = true;
         textCcAddress.ReadOnly           = true;
         textBccAddress.ReadOnly          = true;
         textSubject.ReadOnly             = true;
         textSubject.SpellCheckIsEnabled  = false;                                                                              //Prevents slowness resizing the window, because spell checker runs each time resize event is fired.
         textBodyText.ReadOnly            = true;
         textBodyText.SpellCheckIsEnabled = false;                                                                              //Prevents slowness resizing the window, because spell checker runs each time resize event is fired.
         comboEmailFrom.Visible           = false;
         textFromAddress.Width            = textCcAddress.Width;                                                                //Match the size of Cc Address.
         textFromAddress.Anchor           = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                                                                  | System.Windows.Forms.AnchorStyles.Right))); //Change the anchors to accommodate.
     }
     textSentOrReceived.Text = _emailMessage.SentOrReceived.ToString();
     textFromAddress.Text    = _emailMessage.FromAddress;
     textToAddress.Text      = _emailMessage.ToAddress;
     textCcAddress.Text      = _emailMessage.CcAddress;
     textBccAddress.Text     = _emailMessage.BccAddress;       //if you send an email to yourself, you'll be able to see everyone in the bcc field.
     textSubject.Text        = _emailMessage.Subject;
     textBodyText.Visible    = true;
     webBrowser.Visible      = false;
     if (EmailMessages.IsReceived(_emailMessage.SentOrReceived))
     {
         List <List <Health.Direct.Common.Mime.MimeEntity> > listMimeParts =
             EmailMessages.GetMimePartsForMimeTypes(_emailMessage.RawEmailIn, EmailAddressPreview, "text/html", "text/plain", "image/");
         List <Health.Direct.Common.Mime.MimeEntity> listHtmlParts = listMimeParts[0]; //If RawEmailIn is blank, then this list will also be blank (ex Secure Web Mail messages).
         List <Health.Direct.Common.Mime.MimeEntity> listTextParts = listMimeParts[1]; //If RawEmailIn is blank, then this list will also be blank (ex Secure Web Mail messages).
         _listImageParts = listMimeParts[2];                                           //If RawEmailIn is blank, then this list will also be blank (ex Secure Web Mail messages).
         if (listHtmlParts.Count > 0)                                                  //Html body found.
         {
             textBodyText.Visible = false;
             _isLoading           = true;
             try {
                 webBrowser.DocumentText = EmailMessages.ProcessMimeTextPart(listHtmlParts[0]);
             }
             catch (ApplicationException ex) {
                 webBrowser.DocumentText = "Improperly formatted email. Error displaying email: " + ex.Message;
             }
             webBrowser.Location = textBodyText.Location;
             webBrowser.Size     = textBodyText.Size;
             webBrowser.Anchor   = textBodyText.Anchor;
             webBrowser.Visible  = true;
             if (_listImageParts.Count > 0)
             {
                 butShowImages.Visible = true;
             }
         }
         else if (listTextParts.Count > 0)               //No html body found, however one specific mime part is for viewing in text only.
         {
             textBodyText.Text = EmailMessages.ProcessMimeTextPart(listTextParts[0]);
         }
         else                                            //No html body found and no text body found.  Last resort.  Show all mime parts which are not attachments (ugly).
         {
             textBodyText.Text = _emailMessage.BodyText; //This version of the body text includes all non-attachment mime parts.
         }
         lableUserName.Visible = false;
         textUserName.Visible  = false;
     }
     else                                                //Sent or Unsent/Saved.
     {
         textBodyText.Text     = _emailMessage.BodyText; //Show the body text exactly as typed by the user.
         lableUserName.Visible = true;
         textUserName.Visible  = true;
         textUserName.Text     = (Userods.GetName(_emailMessage.UserNum));          //Blank if 0.
     }
     FillAttachments();
     if (IsComposing)
     {
         FillComboEmail();
         SetHistoricContacts(listHistoricEmailMessages);
     }
     textBodyText.Select();
     Cursor = Cursors.Default;
     if (_isPreview)
     {
         tabAttachmentsShowEmail.TabPages.Remove(tabShowEmail);                 //Do not show Hide Email tab when in Email Preview mode
     }
     else
     {
         InitEmailShowInListBox();
         RefreshShowIn();
     }
 }
Ejemplo n.º 6
0
        private void FillComboEmail()
        {
            //emails to include:
            //1. Default Practice/Clinic
            //2. Me
            //3. All other email addresses not tied to a user
            _listEmailAddresses = new List <EmailAddress>();
            EmailAddress emailAddressDefault = EmailAddresses.GetByClinic(ClinicNum);
            EmailAddress emailAddressMe      = EmailAddresses.GetForUser(Security.CurUser.UserNum);

            if (emailAddressDefault != null)
            {
                _listEmailAddresses.Add(emailAddressDefault);
            }
            if (emailAddressMe != null)
            {
                _listEmailAddresses.Add(emailAddressMe);
            }
            foreach (EmailAddress emailCur in EmailAddresses.GetDeepCopy())
            {
                if ((emailAddressDefault != null && emailCur.EmailUsername == emailAddressDefault.EmailUsername) ||
                    (emailAddressMe != null && emailCur.EmailUsername == emailAddressMe.EmailUsername))
                {
                    continue;
                }
                _listEmailAddresses.Add(emailCur);
            }
            _listEmailAddresses.ForEach(x => {
                if (emailAddressDefault != null && x.EmailUsername == emailAddressDefault.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Practice/Clinic") + " <" + x.EmailUsername + ">");
                }
                else if (emailAddressMe != null && x.EmailUsername == emailAddressMe.EmailUsername)
                {
                    comboEmailFrom.Items.Add(Lan.g(this, "Me") + " <" + x.EmailUsername + ">");
                }
                else
                {
                    comboEmailFrom.Items.Add(x.EmailUsername);
                }
            });
            //not perfect. Tries to guess what the selected combobox item should be based on the current text in FromAddress.
            for (int i = 0; i < _listEmailAddresses.Count; i++)
            {
                string senderAddress = _listEmailAddresses[i].SenderAddress.Trim().ToLower();
                string emailUserName = _listEmailAddresses[i].EmailUsername.Trim().ToLower();
                string fromAddress   = _emailMessage.FromAddress.Trim().ToLower();
                if ((senderAddress != "" && fromAddress.Contains(senderAddress)) ||
                    (emailUserName != "" && fromAddress.Contains(emailUserName)) ||
                    (fromAddress != "" && (emailUserName.Contains(fromAddress) || senderAddress.Contains(fromAddress))))
                {
                    comboEmailFrom.SelectedIndex = i;
                }
            }
            if (!_isComposing || !_isSigningEnabled)
            {
                return;
            }
            if (emailAddressDefault != null)
            {
                SetSig(EmailMessages.GetCertFromPrivateStore(GetOutgoingEmailAddress().EmailUsername));
            }
        }