private void NewWorkItem(IIncomingEmailMessage message) { var workItemUpdates = new Dictionary <string, string>(); InitWorkItemFields(message, workItemUpdates); var workItemId = _workItemManager.CreateWorkItem(workItemUpdates); Logger.InfoFormat("Added new work item {0} for message with subject: {1} (conversation index:{2})", workItemId, message.Subject, message.ConversationIndex); try { // Since the work item *has* been created, failures in this stage are not treated as critical TryApplyFieldOverrides(message, workItemId); ProcessAttachments(message, workItemId); if (_config.WorkItemSettings.AttachOriginalMessage) { string originalMessageFile = message.SaveToFile(); _workItemManager.AttachFiles(workItemId, new List <string> { originalMessageFile }); } } catch (Exception ex) { Logger.ErrorFormat("Exception caught while applying settings to work item {0}\n{1}", workItemId, ex); } _ackEmailHandler.SendAckEmail(message, workItemId.ToString(CultureInfo.InvariantCulture)); }
private void NewWorkItem(IIncomingEmailMessage message) { var workItemUpdates = new Dictionary <string, string>(); InitWorkItemFields(message, workItemUpdates); var overrides = new OverridesExtractor(_config).GetOverrides(message); var workItemId = _workItemManager.CreateWorkItem(workItemUpdates, overrides); Logger.InfoFormat("Added new work item {0} for message with subject: {1} (conversation index:{2})", workItemId, message.Subject, message.ConversationIndex); if (_config.WorkItemSettings.AttachOriginalMessage) { try { ProcessAttachments(message, workItemId); string originalMessageFile = message.SaveToFile(); _workItemManager.AttachFiles(workItemId, new List <string> { originalMessageFile }); } catch (Exception ex) { Logger.ErrorFormat("Exception caught while applying settings to work item {0}\n{1}", workItemId, ex); } } _ackEmailHandler.SendAckEmail(message, workItemId.ToString(CultureInfo.InvariantCulture)); }
private void AttachMessageToWorkItem(IIncomingEmailMessage message, int workItemId, string prefix) { using (var tfc = new TempFileCollection()) { var fileName = string.Format("{0}_{1}_{2}.eml", prefix, DateTime.Now.ToString("yyyyMMdd_hhmmss"), new Random().Next()); var filePath = Path.Combine(Path.GetTempPath(), fileName); message.SaveToFile(filePath); // Remove the file once we're done attaching it tfc.AddFile(filePath, false); _workItemManager.AttachFiles(workItemId, new List <string> { filePath }); } }