Convert EML to MSG

If the message contains nested MSG files, to retain the nested MSG files as MSG files after import, select Extract nested messages > Import all attached emails as EML/MSG files option in the Import settings tab.

Sample code for using this feature.

using System;
using System.Collections.Generic;
using Kofax.KCS.ImportConnector.Config;
using Kofax.KCS.ImportConnector.Messages;
using Kofax.KCS.ImportConnector.Scripting;

namespace Kofax.KCS.ImportConnector.ScriptingSample
{
    /*
     * IDocumentConverterScript interface extends the functionality of IReRouteScript script.
     * IDocumentConverterScript exposes DocumentConverter() API along with ReRoute() API.
     * Using the implementation of IDocumentConverter interface in DocumentConverter() API, 
     * we can acheive the following functionality:
     * 1) Combine Body of a message with individual Attachments. (Check AppendBodyToAttachments_FR7043.cs in KCSImportScriptingSample.zip)
     * 2) Convert any Documents to PDF and/or Tiff. (Check SampleDocumentConverterScript.cs in KCSImportScriptingSample.zip)
     * 3) Concatenate individual PDFs to a single PDF/A document.(Check SampleDocumentCombineScript.cs in KCSImportScriptingSample.zip)
     * 4) Extract Zipped archives.(Check SampleUnzipScript.cs in KCSImportScriptingSample.zip)
     * */

    /// <summary>
    /// This sample script demonstrates the Document Conversion 
    /// functionality exposed by the interface IDocumentConverterScript
    /// </summary>
    public class SampleDocumentConverterScript : IDocumentConverterScript
    {
        /// <summary>
        /// This method is used to Convert dicuments to Tiff/PDF
        /// </summary>
        /// <param name="message">The message to be imported into KC</param>
        /// <param name="converter">The Document Converter Interface object</param>
        /// <returns></returns>
        public ConversionResult DocumentConverter(Message message, IDocumentConverter converter)
        {
            ConversionResult result = new ConversionResult();

            if (converter != null)
            {
                List<Attachment> convertedAttachments = null;
                List<Attachment> convertedAttachments1 = new List<Attachment>();
                DocumentConversionOptions options = new DocumentConversionOptions();

                /* ConversionDetails class exposes the following settings:
                 *  PDF Normalization
                 *  Flattening portfolio PDFs using Adobe Life Cycle
                 *  Image Quality
                 *  Image Resolution
                 *  Image Scaling and Image Coding
                 *  Smoothening and Rendering Flags
                */

                options.ConversionDetails = new ConversionDetails();

                // Configuring PDF Normalization and Flattening portfolio PDFs.
                options.ConversionDetails.isPdfNormalizationEnabled = true;
                options.ConversionDetails.isALCFlatteningEnabled = true;

                // To Convert documents to Tiff or PDF, configure the required options below.

                // Configuring PDF conversion.
                // NOTE: If the input is a PDF document, and PDF normalization is not enabled,
                // then output will be empty.
                //options.Pdf = 1;

                // Configuring Tif conversion.
                //options.Tif = 1;

                //Configuring Msg conversion.
                //For EML input only
                options.Msg = 1;

                //Configuring Msg conversion.
                //For MSG input only
                //options.Eml = 1;

                // Call the Convert API with the documents which needs conversion as input.
                foreach (Attachment att in message.BodyAttachments)
                {
                   if(att.Extension.ToLower()=="eml")
                   {
                     result = converter.Convert(out convertedAttachments, att, options);
                     if (result.Code == 0 && convertedAttachments != null && convertedAttachments.Count > 0)
                       {
                            // Add the converted documents to the message 
                            // so that they will be imported into Kofax Capture.
                            convertedAttachments1.AddRange(convertedAttachments);
                       }
                   }
                }
                if(convertedAttachments1 != null && convertedAttachments1.Count > 0)
                {
                    message.BodyAttachments.AddRange(convertedAttachments1);
                }
            }

            return result;
        }

        public eMessageScriptCode ReRoute(Message message, object extension)
        {
            return eMessageScriptCode.Other;
        }
    }
}

To enable this feature, do the following:

  1. Copy the above sample script and save it as SampleDocumentConverterScript.cs file on your local folder.
  2. Open KC Plug-In.
  3. Navigate to Destination configuration > Additional settings.
  4. In the Rerouting\Document conversion script path field, type or click browse to go to the path containing the .cs file and select it.
  5. Restart the KC Plug-In service.