コード例 #1
0
        public CreateAccountContact(Outlook.MailItem mailItem)
        {
            InitializeComponent();

            try
            {
                if (mailItem != null)
                {
                    SafeMailItem safeMail = new SafeMailItem();

                    safeMail.Item = mailItem;

                    txtEmail.Text = safeMail.Sender.SMTPAddress;

                    if (!String.IsNullOrEmpty(safeMail.SenderName))
                    {
                        string[] nameCommaSplit = safeMail.SenderName.Split(',');
                        string[] nameSpaceSplit = safeMail.SenderName.Split(' ');

                        if (nameCommaSplit.Length > 1)
                        {
                            txtFName.Text = nameCommaSplit[1].Trim();
                            txtLName.Text = nameCommaSplit[0].Trim();
                        }
                        else if (nameSpaceSplit.Length > 1)
                        {
                            txtFName.Text = nameSpaceSplit[0].Trim();
                            txtLName.Text = nameSpaceSplit[1].Trim();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
 public ContactFound(string id, SafeMailItem safeMail)
 {
     InitializeComponent();
     contactId = id;
     curEmail = safeMail;
 }
コード例 #3
0
        void cmdOpportunities_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            try
            {
                if (Application.ActiveExplorer().Selection.Count > 1)
                {
                    MessageBox.Show("Please only select a single email.");
                    return;
                }

                Outlook.MailItem mail = Application.ActiveExplorer().Selection[1] as Outlook.MailItem;

                SafeMailItem safeMail = new SafeMailItem();

                safeMail.Item = mail;

                string add = safeMail.Sender.SMTPAddress;

                if (!String.IsNullOrEmpty(add))
                {
                    Regex regex = new Regex("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$", RegexOptions.IgnoreCase);

                    if (regex.IsMatch(add))
                    {
                        contactId = EmailSearch(add,"Contacts");
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }

                if (contactId == null)
                {
                    MessageBox.Show("Could not find contact");
                }
                else
                {
                    Form frmOpportunities = new Opportunities(contactId);
                    frmOpportunities.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        void cmdGotoLead_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            try
            {
                if (Application.ActiveExplorer().Selection.Count > 1)
                {
                    MessageBox.Show("Please only select a single email.");
                    return;
                }

                Outlook.MailItem mail = Application.ActiveExplorer().Selection[1] as Outlook.MailItem;

                SafeMailItem safeMail = new SafeMailItem();

                safeMail.Item = mail;

                string add = safeMail.Sender.SMTPAddress;

                if (!String.IsNullOrEmpty(add))
                {
                    Regex regex = new Regex("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$", RegexOptions.IgnoreCase);

                    if (regex.IsMatch(add))
                    {
                        leadId = EmailSearch(add,"Leads");
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }

                if (leadId == null)
                {
                    MessageBox.Show("Could not find lead");
                }
                else
                {
                    Process iexplore = new Process();

                    string tempURL = Properties.Settings.Default.SDATA;

                    tempURL += "/{0}/Lead.aspx?entityid={1}";

                    iexplore.StartInfo.FileName = "iexplore.exe";
                    iexplore.StartInfo.Arguments = String.Format(tempURL, "SlxClient", leadId);
                    iexplore.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
        void cmdCreateLead_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            try
            {
                if (Application.ActiveExplorer().Selection.Count > 1)
                {
                    MessageBox.Show("Please only select a single email.");
                    return;
                }

                Outlook.MailItem mail = Application.ActiveExplorer().Selection[1] as Outlook.MailItem;

                SafeMailItem safeMail = new SafeMailItem();

                safeMail.Item = mail;

                string add = safeMail.Sender.SMTPAddress;

                if (!String.IsNullOrEmpty(add))
                {
                    Regex regex = new Regex("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$", RegexOptions.IgnoreCase);

                    if (regex.IsMatch(add))
                    {
                        Form frmCreateLead = new CreateLead(mail);
                        //frmCreateLead.FormClosed += new FormClosedEventHandler(frmCreate_FormClosed);
                        frmCreateLead.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Not a valid email address");
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #6
0
 public CreateTicket(SDataPayload payload, SafeMailItem safeEmail)
 {
     InitializeComponent();
     contactPayload = payload;
     curEmail = safeEmail;
 }
コード例 #7
0
ファイル: Utils.cs プロジェクト: ProjectECS/ECS
 internal static string GetRecordKey(SafeMailItem safItem)
 {
     const string SOURCE = CLASS_NAME + "GetRecordKey";
     try
     {
         object prop = safItem.Fields[ThisAddIn.PR_RECORD_KEY];
         if (prop != null)
         {
             var array = (object[]) prop;
             var bytes = new byte[array.Length];
             for (var i = 0; i < bytes.Length; i++)
             {
                 bytes[i] = Convert.ToByte(array[i]);
             }
             return BitConverter.ToString(bytes).Replace("-","");
         }
     }
     catch (Exception ex)
     {
         Logger.Error(SOURCE, ex.ToString());
     }
     return "";
 }
コード例 #8
0
 private void RemoveAllAttachmentsFromMessage(SafeMailItem msgItem, OlBodyFormat format)
 {
     Attachments attachments = msgItem.Attachments;
     for (int i = attachments.Count; i > 0; i--)
     {
         Attachment attachment = attachments.Item(i);
         if (!MapiSignatureInspector.IsSignature(attachment, format))
         {
             attachment.Delete();
         }
         Marshal.ReleaseComObject(attachment);
     }
     Marshal.ReleaseComObject(attachments);
 }
コード例 #9
0
        private void AddAttachmentToMessage(IProtectAttachment attachment, SafeMailItem message)
        {
            Attachments attachments = message.Attachments;
            Attachment newAttachment = attachments.Add(attachment.FileName,
                                                       OlAttachmentType.olByValue,
                                                       attachment.Index,
                                                       attachment.Name);
            string displayname = attachment.Name;

            if (string.IsNullOrEmpty(displayname) || string.IsNullOrEmpty(displayname.Trim()))
            {
                newAttachment.set_Fields(Constants.PR_DISPLAY_NAME_W, "Untitled Attachment");
            }

            Marshal.ReleaseComObject(attachments);
            Marshal.ReleaseComObject(newAttachment);
        }
コード例 #10
0
        private void GatherSLXInformation()
        {
            //Creating a SafeEmail object so I can always get SMTP address even from Exchange emails
            SafeMailItem safeMail = new SafeMailItem();

            safeMail.Item = curEmail;

            string contactId = EmailSearch(safeMail.Sender.SMTPAddress, "Contacts");

            string leadId = EmailSearch(safeMail.Sender.SMTPAddress, "Leads");

            if (!this.InvokeRequired)
            {
                ClearAll();
            }
            else
            {
                this.Invoke(new ClearAll(this.ClearAll), null);
            }

            if (!String.IsNullOrEmpty(contactId))
            {
                SDataSingleResourceRequest tempContact = new SDataSingleResourceRequest(mydataService);

                tempContact.ResourceKind = "Contacts";

                tempContact.Include = "Account,AccountManager/UserInfo,Address";

                tempContact.ResourceSelector = "('" + contactId + "')";

                AtomEntry contactEnty = tempContact.Read();

                SDataPayload contact = (SDataPayload)contactEnty.GetSDataPayload();
                SDataPayload contactAcct = (SDataPayload)contact.Values["Account"];
                SDataPayload contactMgr = (SDataPayload)contact.Values["AccountManager"];
                SDataPayload contactMgrInfo = (SDataPayload)contactMgr.Values["UserInfo"];
                SDataPayload contactAddress = (SDataPayload)contact.Values["Address"];

                if (!this.InvokeRequired)
                {
                    UpdateContactUI(contact);
                    UpdateAccountUI(contactAcct);
                    UpdateManagerUI(contactMgrInfo);
                    UpdateOppoUI(contactId);
                    UpdateTicketUI(contactId);
                    UpdateAddressUI((contactAddress.Values["FullAddress"] != null ? contactAddress.Values["FullAddress"].ToString() : ""));
                }
                else
                {
                    this.BeginInvoke(new UpdateUI(this.UpdateContactUI), contact);
                    this.BeginInvoke(new UpdateUI(this.UpdateAccountUI), contactAcct);
                    this.BeginInvoke(new UpdateUI(this.UpdateManagerUI), contactMgrInfo);
                    this.BeginInvoke(new UpdateOppoUI(this.UpdateOppoUI), contactId);
                    this.BeginInvoke(new UpdateTicketUI(this.UpdateTicketUI), contactId);
                    this.BeginInvoke(new UpdateAddressUI(this.UpdateAddressUI), (contactAddress.Values["FullAddress"] != null ? contactAddress.Values["FullAddress"].ToString() : ""));
                }
            }

            if (!String.IsNullOrEmpty(leadId))
            {
                SDataSingleResourceRequest tempLead = new SDataSingleResourceRequest(mydataService);
                tempLead.ResourceKind = "Leads";
                tempLead.Include = "Address";
                tempLead.ResourceSelector = "('" + leadId + "')";
                AtomEntry leadEnty = tempLead.Read();
                SDataPayload lead = (SDataPayload)leadEnty.GetSDataPayload();

                SDataPayload tempLeadAddress = (SDataPayload)lead.Values["Address"];
                string leadAddressId = tempLeadAddress.Key;
                SDataSingleResourceRequest tempLeadAddressRequest = new SDataSingleResourceRequest(mydataService);
                tempLeadAddressRequest.ResourceKind = "LeadAddresses";
                tempLeadAddressRequest.ResourceSelector = "('" + leadAddressId + "')";
                AtomEntry leadAddressEnty = tempLeadAddressRequest.Read();
                SDataPayload leadAddress = (SDataPayload)leadAddressEnty.GetSDataPayload();

                if (!this.InvokeRequired)
                {
                    UpdateLeadUI(lead);
                    UpdateAddressUI((leadAddress.Values["FullAddress"] != null ? leadAddress.Values["FullAddress"].ToString() : ""));
                }
                else
                {
                    this.BeginInvoke(new UpdateUI(this.UpdateLeadUI), lead);
                    this.BeginInvoke(new UpdateAddressUI(this.UpdateAddressUI), (leadAddress.Values["FullAddress"] != null ? leadAddress.Values["FullAddress"].ToString() : ""));
                }
            }
        }
コード例 #11
0
        void frmCreate_FormClosed(object sender, FormClosedEventArgs e)
        {
            CreateAccountContact frm = (CreateAccountContact)sender;

            Outlook.MailItem mail = Application.ActiveExplorer().Selection[1] as Outlook.MailItem;

            SafeMailItem safeMail = new SafeMailItem();

            safeMail.Item = mail;

            string add = safeMail.Sender.SMTPAddress;

            contactId = EmailSearch(add);

            if ((frm.DialogResult == DialogResult.Yes) & (!String.IsNullOrEmpty(contactId)))
            {
                Form frmContactFound = new ContactFound(contactId, safeMail);
                frmContactFound.ShowDialog();
            }
        }