Skip to main content
Kofax

Attachment objects in custom Email Import Script

18756

QAID # 18756 Published 

Question / Problem:

I am looking into modifying a KIC script for email importing.

What kind of information will I expect to see in the Attachment objects?

Answer / Solution:

This kind of information can be easily retrieved and written to a text file using a StreamWriter in the ManageMessageFiles method:

public void ManageMessageFiles(ReadonlyMessage message,
                                List
    messageBody,
                                List
    attachments,
                                object extension)
{
    using (StreamWriter sw = new StreamWriter(@"c:\KICInfo.txt", true))
    {
        // iterate through the message body renditions
        foreach (Attachment msgBody in messageBody)
        {
            // Output some info about the Message Body
            sw.WriteLine("***** Message Body Info *****");
            sw.WriteLine("IsBody: " + msgBody.IsBody.ToString());
            sw.WriteLine("CreationDate: " + msgBody.CreationDate.ToString());
            sw.WriteLine("ModificationDate: " + msgBody.ModificationDate.ToString());
            sw.WriteLine("ContentType: " + msgBody.ContentType.ToString());
            sw.WriteLine("OriginalContentType: " + msgBody.OriginalContentType.ToString());
            sw.WriteLine("ContentDisposition: " + msgBody.ContentDisposition);
            sw.WriteLine("ContentID: " + msgBody.ContentID.ToString());
            sw.WriteLine("CaptureFileName: " + msgBody.CaptureFileName);
            sw.WriteLine("OriginalFileName: " + msgBody.OriginalFileName);
            sw.WriteLine("Extension: " + msgBody.Extension);
            sw.WriteLine("HierarchicalPosition: " + msgBody.HierarchicalPosition.ToString());
            sw.WriteLine("Id: " + msgBody.Id.ToString());
            sw.WriteLine("IsOriginal: " + msgBody.IsOriginal.ToString());
            sw.WriteLine("isOriginalCopy: " + msgBody.isOriginalCopy.ToString());
            sw.WriteLine("IsOriginalEml: " + msgBody.IsOriginalEml.ToString());
            sw.WriteLine("IsXmlRendering: " + msgBody.IsXmlRendering.ToString());
            sw.WriteLine("------------------------------------------------------------");
        }
        //for the attachments do the same - iterate through the attachments
        foreach (Attachment att in attachments)
        {
            // Output some info about the Attachment
            sw.WriteLine("***** Attachment Info *****");
            sw.WriteLine("IsBody: " + att.IsBody.ToString());
            sw.WriteLine("CreationDate: " + att.CreationDate.ToString());
            sw.WriteLine("ModificationDate: " + att.ModificationDate.ToString());
            sw.WriteLine("ContentType: " + att.ContentType.ToString());
            sw.WriteLine("OriginalContentType: " + att.OriginalContentType.ToString());
            sw.WriteLine("ContentDisposition: " + att.ContentDisposition);
            sw.WriteLine("ContentID: " + att.ContentID.ToString());
            sw.WriteLine("CaptureFileName: " + att.CaptureFileName);
            sw.WriteLine("OriginalFileName: " + att.OriginalFileName);
            sw.WriteLine("Extension: " + att.Extension);
            sw.WriteLine("HierarchicalPosition: " + att.HierarchicalPosition.ToString());
            sw.WriteLine("Id: " + att.Id.ToString());
            sw.WriteLine("IsOriginal: " + att.IsOriginal.ToString());
            sw.WriteLine("isOriginalCopy: " + att.isOriginalCopy.ToString());
            sw.WriteLine("IsOriginalEml: " + att.IsOriginalEml.ToString());
            sw.WriteLine("IsXmlRendering: " + att.IsXmlRendering.ToString());
            sw.WriteLine("------------------------------------------------------------");
        }
    }
}

Importing a message containing three TIFF file attachments results in the text file output below:

***** Message Body Info *****
IsBody: True
CreationDate: 1/1/0001 12:00:00 AM
ModificationDate: 1/1/0001 12:00:00 AM
ContentType: image/tiff
OriginalContentType: BINARY_nonIMAGE
ContentDisposition: inline
ContentID:
CaptureFileName:
OriginalFileName: content.html
Extension: TIF
HierarchicalPosition: 0
Id: 18a2a3d7-56bf-465e-ab78-6e38bb6adc9b
IsOriginal: False
isOriginalCopy: False
IsOriginalEml: False
IsXmlRendering: False
------------------------------------------------------------
***** Attachment Info *****
IsBody: False
CreationDate: 10/7/2013 11:16:46 AM
ModificationDate: 12/19/2011 12:28:06 PM
ContentType: image/tiff
OriginalContentType: BINARY_IMAGE
ContentDisposition: attachment
ContentID:
CaptureFileName:
OriginalFileName: 2.tif
Extension: tif
HierarchicalPosition: 1
Id: 6b9addb4-512d-45cf-847b-a6b9eeebb16e
IsOriginal: True
isOriginalCopy: False
IsOriginalEml: False
IsXmlRendering: False
------------------------------------------------------------
***** Attachment Info *****
IsBody: False
CreationDate: 10/7/2013 11:17:24 AM
ModificationDate: 12/19/2011 12:28:06 PM
ContentType: image/tiff
OriginalContentType: BINARY_IMAGE
ContentDisposition: attachment
ContentID:
CaptureFileName:
OriginalFileName: 1.tif
Extension: tif
HierarchicalPosition: 3
Id: 8a6564b0-3b7e-400c-857a-0008f16b9fac
IsOriginal: True
isOriginalCopy: False
IsOriginalEml: False
IsXmlRendering: False
------------------------------------------------------------

Applies to:

Product Version Category
CAPTURE 10.0 Import Connector - Email
CAPTURE 10.1 Import Connector - Email