private void ArchiveEmailThread(SuiteCRMClient.clsEmailArchive objEmail, int intArchiveType, string strExcludedEmails = "") { try { if (SuiteCRMUserSession != null) { while (SuiteCRMUserSession.AwaitingAuthentication == true) { System.Threading.Thread.Sleep(1000); } if (SuiteCRMUserSession.id != "") { objEmail.SuiteCRMUserSession = SuiteCRMUserSession; objEmail.Save(strExcludedEmails); } } } catch (Exception ex) { string strLog; strLog = "------------------" + System.DateTime.Now.ToString() + "-----------------\n"; strLog += "ArchiveEmailThread method General Exception:" + "\n"; strLog += "Message:" + ex.Message + "\n"; strLog += "Source:" + ex.Source + "\n"; strLog += "StackTrace:" + ex.StackTrace + "\n"; strLog += "Data:" + ex.Data.ToString() + "\n"; strLog += "HResult:" + ex.HResult.ToString() + "\n"; strLog += "-------------------------------------------------------------------------" + "\n"; clsSuiteCRMHelper.WriteLog(strLog); ex.Data.Clear(); } }
private void ArchiveEmail(Outlook.MailItem objMail, int intArchiveType, string strExcludedEmails = "") { try { SuiteCRMClient.clsEmailArchive objEmail = new SuiteCRMClient.clsEmailArchive(); objEmail.From = objMail.SenderEmailAddress; objEmail.To = ""; foreach (Outlook.Recipient objRecepient in objMail.Recipients) { if (objEmail.To == "") { objEmail.To = objRecepient.Address; } else { objEmail.To += ";" + objRecepient.Address; } } objEmail.Subject = objMail.Subject; objEmail.Body = objMail.Body; objEmail.HTMLBody = objMail.HTMLBody; objEmail.ArchiveType = intArchiveType; foreach (Outlook.Attachment objMailAttachments in objMail.Attachments) { objEmail.Attachments.Add(new SuiteCRMClient.clsEmailAttachments { DisplayName = objMailAttachments.DisplayName, FileContentInBase64String = Base64Encode(objMailAttachments, objMail) }); } System.Threading.Thread objThread = new System.Threading.Thread(() => ArchiveEmailThread(objEmail, intArchiveType, strExcludedEmails)); objThread.Start(); } catch (Exception ex) { string strLog; strLog = "------------------" + System.DateTime.Now.ToString() + "-----------------\n"; strLog += "ArchiveEmail method General Exception:" + "\n"; strLog += "Message:" + ex.Message + "\n"; strLog += "Source:" + ex.Source + "\n"; strLog += "StackTrace:" + ex.StackTrace + "\n"; strLog += "Data:" + ex.Data.ToString() + "\n"; strLog += "HResult:" + ex.HResult.ToString() + "\n"; strLog += "-------------------------------------------------------------------------" + "\n"; clsSuiteCRMHelper.WriteLog(strLog); ex.Data.Clear(); } }
private void ArchiveEmail(Outlook.MailItem objMail, int intArchiveType, string strExcludedEmails = "") { try { SuiteCRMClient.clsEmailArchive objEmail = new SuiteCRMClient.clsEmailArchive(); objEmail.From = objMail.SenderEmailAddress; objEmail.To = ""; foreach (Outlook.Recipient objRecepient in objMail.Recipients) { if (objEmail.To == "") objEmail.To = objRecepient.Address; else objEmail.To += ";" + objRecepient.Address; } objEmail.Subject = objMail.Subject; objEmail.Body = objMail.Body; objEmail.HTMLBody = objMail.HTMLBody; objEmail.ArchiveType = intArchiveType; foreach (Outlook.Attachment objMailAttachments in objMail.Attachments) { objEmail.Attachments.Add(new SuiteCRMClient.clsEmailAttachments { DisplayName = objMailAttachments.DisplayName, FileContentInBase64String = Base64Encode(objMailAttachments, objMail) }); } System.Threading.Thread objThread = new System.Threading.Thread(() => ArchiveEmailThread(objEmail, intArchiveType, strExcludedEmails)); objThread.Start(); } catch (Exception ex) { string strLog; strLog = "------------------" + System.DateTime.Now.ToString() + "-----------------\n"; strLog += "ArchiveEmail method General Exception:" + "\n"; strLog += "Message:" + ex.Message + "\n"; strLog += "Source:" + ex.Source + "\n"; strLog += "StackTrace:" + ex.StackTrace + "\n"; strLog += "Data:" + ex.Data.ToString() + "\n"; strLog += "HResult:" + ex.HResult.ToString() + "\n"; strLog += "-------------------------------------------------------------------------" + "\n"; clsSuiteCRMHelper.WriteLog(strLog); ex.Data.Clear(); } }