private void InitWorkItemFields(IIncomingEmailMessage message, Dictionary <string, string> workItemUpdates) { var resolver = new SpecialValueResolver(message, _workItemManager.GetNameResolver()); workItemUpdates["Title"] = resolver.Subject; var rawConversationIndex = message.ConversationId; workItemUpdates[_config.WorkItemSettings.ConversationIndexFieldName] = rawConversationIndex.Substring(0, Math.Min(rawConversationIndex.Length, TfsTextFieldMaxLength)); foreach (var defaultFieldValue in _config.WorkItemSettings.DefaultFieldValues) { workItemUpdates[defaultFieldValue.Field] = resolver.Resolve(defaultFieldValue.Value); } string emailBodyFieldName = _config.WorkItemSettings.EmailBodyFieldName; if (!String.IsNullOrEmpty(emailBodyFieldName)) { if (workItemUpdates.Keys.Contains(emailBodyFieldName)) { Logger.Warn($"Field {emailBodyFieldName} is defined for mapping in {nameof(_config.WorkItemSettings.EmailBodyFieldName)} for mapping. The DefaultValueDefinition entry will be ignored."); } workItemUpdates[emailBodyFieldName] = MailHeaderExtractor.GetHtmlBody(_config, message, resolver.HtmlMessageBody); } }
public static string GetHtmlBody(Config.InstanceConfig config, IIncomingEmailMessage message, string htmlBody) { string newHtmlBody = ""; if (config.WorkItemSettings.AddEmailHeaderToMessageDescription) { var extractor = new MailHeaderExtractor(message); newHtmlBody = Regex.Replace(htmlBody, @"(<body.*?>)", "$1" + extractor.GetHeaderHtml()); } else { newHtmlBody = htmlBody; } return(newHtmlBody); }