Example #1
0
 public void AddRecipToMessage(docDB.RecipientRow r, docDB.DocumentRow d, RecipType rtype)
 {
     try
     {
         docDB.RecipientRow newr = (docDB.RecipientRow)Add(d);
         DoNotResolve = true;
         newr.Type    = ((int)rtype).ToString();
         if (!r.IsOfficeIdNull())
         {
             newr.OfficeId = r.OfficeId;
         }
         if (!r.IsOfficerIdNull())
         {
             newr.OfficerId = r.OfficerId;
         }
         if (!r.IsAddressNull())
         {
             newr.Address = r.Address;
         }
         if (!r.IsNameNull())
         {
             newr.Name = r.Name;
         }
     }
     catch (Exception x)
     {
     }
     DoNotResolve = false;
 }
        private void FormConfirmAddress_Load(object sender, EventArgs e)
        {
            listViewInnerAddress.Columns.Add("Inner", listViewInnerAddress.Width, HorizontalAlignment.Left);
            listViewOuterAddress.Columns.Add("Outer", listViewInnerAddress.Width, HorizontalAlignment.Left);

            RecipType[] recipTypes = new RecipType[] {
                new RecipType(Outlook.OlMailRecipientType.olTo, "To:"),
                new RecipType(Outlook.OlMailRecipientType.olCC, "CC:"),
                new RecipType(Outlook.OlMailRecipientType.olBCC, "BCC:"),
            };

            string myDomain;

            try {
                myDomain = mail.Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress.Split('@')[1];
            } catch (Exception) {
                myDomain = ".";
            }
            foreach (RecipType recipType in recipTypes)
            {
                foreach (Outlook.Recipient recip in mail.Recipients)
                {
                    if ((Outlook.OlMailRecipientType)recip.Type == recipType.type)
                    {
                        var item = new ListViewItem();
                        item.Font = new Font(item.Font, item.Font.Style | FontStyle.Bold);
                        string smtpAddress;
                        try {
                            smtpAddress = recip.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E").ToString().Trim();
                        } catch (Exception) {
                            smtpAddress = "?";
                        }
                        item.Text = recipType.text + "  " +
                                    (recip.Name.Trim().Equals(smtpAddress) ? smtpAddress : recip.Name.Trim() + " <" + smtpAddress + ">");
                        if (smtpAddress.EndsWith("@" + myDomain) || smtpAddress.EndsWith("." + myDomain))
                        {
                            listViewInnerAddress.Items.Add(item);
                        }
                        else
                        {
                            listViewOuterAddress.Items.Add(item);
                        }
                    }
                }
            }
            listViewInnerAddress.Left = listViewOuterAddress.Left = MARGIN;
            listViewInnerAddress.Top  = MARGIN;
            buttonSend.Enabled        = false;
            AlignParts();
        }