limiting KIC email import attachment types

Ascent Collection Server

limiting KIC email import attachment types

Postby Hando Penu » Fri Jul 04, 2014 12:42 am

Hi!

I have KIC e-mail import configured to scan a mailbox and extract invoice files (PDF, TIFF, XLS, DOC) from there. KIC can convert these non-image files to PDF without any problems. But sometimes someone sends there something, that KIC should ignore... If it is empty message, then no problems. But sometimes there will be sent PDF file + XML file. And this causes problems - the attachments are imported and as XML file is not supported by KTM, it faults there, causing entire batch to QC. Does anyone know, is there a way to limit file types KIC will import from e-mails? At the moment I need to ignore XML files in attachments...
Hando Penu
Participant
 
Posts: 362
Joined: Thu Jul 17, 2008 9:42 pm

Re: limiting KIC email import attachment types

Postby MMIDMIS » Tue Jul 08, 2014 6:43 am

I have the same problem with VCF cards in a senders signature.

We reject the entire batch rather than sending to QC and send it via email to our users who remove the offending problem and reprocess.
MMIDMIS
Participant
 
Posts: 126
Joined: Thu Apr 22, 2010 6:21 pm

Re: limiting KIC email import attachment types

Postby DavidCrewe » Tue Jul 08, 2014 7:16 am

You could also use a workflow agent to strip away any unsupported or unwanted attachments - I've done this a few times with other clients using various email importers.
David Crewe

Check out our set of custom add-ons for Kofax Capture - www.DavidCrewe.com/products.html
DavidCrewe
Participant
 
Posts: 232
Joined: Tue Apr 29, 2008 2:24 am
Location: UK

Re: limiting KIC email import attachment types

Postby Warpfield » Tue Jul 15, 2014 12:31 pm

For this you would implement a KIC script, (C# code). Add code to the BeforeMessageImport method to iterate through the message attachments collection and setting the DoImport flag to false if it is not to be imported. Here is an example:

Code: Select all
public void BeforeMessageImport(IDictionary<string, string> indexFields,
                        IDictionary<string, string> folderFields,
                        IDictionary<string, string> batchFields,
                        List<Attachment> messageBody,
                        List<Attachment> attachments,
                        object extension)
{

    foreach (Attachment abc in attachments)
    {
        if (abc.Extension.ToLower() == "pdf")
        {
            abc.DoImport = false;
        }
    }
}
If they are going to hate you anyway for what you do, then you might as well put forth your best effort.
User avatar
Warpfield
Participant
 
Posts: 62
Joined: Tue Apr 10, 2007 8:11 am

Re: limiting KIC email import attachment types

Postby Hando Penu » Wed Jul 16, 2014 1:33 am

Thanks for the idea!
I'll try it.

Hando
Hando Penu
Participant
 
Posts: 362
Joined: Thu Jul 17, 2008 9:42 pm

Re: limiting KIC email import attachment types

Postby garyswaggerty » Wed Jul 23, 2014 6:02 am

Is there a tutorial on how to use KIC scripts anywhere?
I've tried adding the code above to the sample script and cannot make it work. It continues to import the pdf attachments.


thanks,
gary
garyswaggerty
Participant
 
Posts: 12
Joined: Wed Jan 11, 2012 7:26 am

Re: limiting KIC email import attachment types

Postby Hando Penu » Wed Jul 30, 2014 11:34 pm

Hi!

Some samples are located in C:\Program Files\Kofax\KCIC-AEF\KC Plug-In\ScriptSample\KCSImportScriptingSample.zip file and there is some reference to this Import connector Developers Guide. To be honest, it is not the best...

Hando
Hando Penu
Participant
 
Posts: 362
Joined: Thu Jul 17, 2008 9:42 pm

Re: limiting KIC email import attachment types

Postby Hando Penu » Mon Sep 22, 2014 5:20 am

Hi!

I'd like to share fine piece of code by Wolfgang Radl https://www.linkedin.com/groups/KTM-server-is-not-processing-1414587.S.5918433699841482755?trk=groups_most_recent-0-b-ttl&goback=.gmr_1414587 that does all what's needed:
Code: Select all

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Kofax.KCS.ImportConnector.Messages;
using Kofax.KCS.ImportConnector.Scripting;


namespace Kofax.KCS.ImportConnector.ScriptingSample
{
    public class ImportOnlySpecificFiles : IDocumentScript2
    {

        // Array with extensions to be imported
        string[] IMPORT_ATTACHMENT_EXT = { ".PDF", ".JPG", ".TIF", ".DOCX", ".DOC", ".XLSX", ".XLS", ".PNG" };

        #region IDocumentScript2 Members


        /// <summary>
        /// Called before the import content and import order is determined
        /// Body and attachment content and import order can be maniuplated in this function
        /// </summary>
        /// <param name="messageBody">A readonly instance of the message being imported</param>
        /// <param name="messageBody">The list of received message bodies</param>
        /// <param name="attachments">The list of received message attachments</param>
        /// <param name="extension">Reserved for future use</param>
        public void ManageMessageFiles(ReadonlyMessage message,
                               List<Attachment> messageBody,
                               List<Attachment> attachments,
                               object extension)
        {


            for (int i = messageBody.Count - 1; i >= 0; i--)
            {
                if (!IsValidExtension(Path.GetExtension(messageBody[i].OriginalFileName)))
                {
                    messageBody.RemoveAt(i);
                }
            }

            for (int i = attachments.Count - 1; i >= 0; i--)
            {
                if (!IsValidExtension(Path.GetExtension(attachments[i].OriginalFileName)))
                {
                    attachments.RemoveAt(i);
                }

            }
        }

        /// <summary>
        ///  Called before a message import into KC is started
        /// </summary>
        /// <param name="indexFields">The list of index fields defined in the configured document class. If document class not defined this will be empty.</param>
        /// <param name="folderFields">The list of folder fields defined in the configured folder class. If folder class not defined this will be empty.</param>
        /// <param name="batchFields">The list of batch fields defined in the configured batch class.</param>
        /// <param name="messageBody">The list of received message bodies</param>
        /// <param name="attachments">The list of received message attachments</param>
        /// <param name="extension">Reserved for future use.</param>
        public void BeforeMessageImport(IDictionary<string, string> indexFields,
                                IDictionary<string, string> folderFields,
                                IDictionary<string, string> batchFields,
                                List<Attachment> messageBody,
                                List<Attachment> attachments,
                                object extension)
        {

        }

        /// <summary>
        /// Called before a KC document is created in KC
        /// </summary>
        /// <param name="indexFields">The list of index fields defined in the configured document class. If document class not defined this will be empty.</param>
        /// <param name="folderFields">The list of folder fields defined in the configured folder class. If folder class not defined this will be empty.</param>
        /// <param name="batchFields">The list of batch fields defined in the configured batch class.</param>
        /// <param name="messageBody">The list of received message bodies</param>
        /// <param name="attachments">The list of received message attachments</param>
        /// <param name="extension">Reserved for future use.</param>
        public void BeforeDocumentImport(IDictionary<string, string> indexFields,
                                  IDictionary<string, string> folderFields,
                                  IDictionary<string, string> batchFields,
                                  List<Attachment> messageBody,
                                  List<Attachment> attachments,
                                  object extension)
        {

        }

        #endregion


        // Check if attachment based on the extension list is valid
        public bool IsValidExtension(string ext)
        {
            for (int i = 0; i < IMPORT_ATTACHMENT_EXT.Length; i++)
            {
                if (ext.ToUpper() == IMPORT_ATTACHMENT_EXT[i].ToUpper())
                {
                    return true;
                }
            }
            return false;
        }



    }

}

Hando Penu
Participant
 
Posts: 362
Joined: Thu Jul 17, 2008 9:42 pm


Return to Kofax Capture Import Connector

Who is online

Users browsing this forum: No registered users and 1 guest

cron