image2data

Der Tech-Blog

...weitermachen, wo OCR aufhört

Plugin "E-Mail-Daten extrahieren" (i2dxEML)

Feb 152015

Eingehende E-Mails können mit Hilfe des image2data-Plugins "E-Mail-Daten extrahieren" (i2dxEML) analysiert und extrahiert werden. Das folgende Skript nimmt den Namen einer E-Mail-Datei über eine InputBox entgegen und extrahiert sowohl die darin enthaltenen Attachments als auch alle anderen notwendigen Informationen, wie z.B. Absender, Betreff und Text.

// **************************************************************
// * sample_i2dxeml.i2dspt                                      *
// *                                                            *
// * Sample script for the i2dxEML (e-mail extraction) plugin   *
// * REQUIRES THE INSTALLED PLUGIN TO COMPILE AND RUN!          *
// *                                                            *
// * Press F9 to execute the code or F7/F8 to debug it          *
// *                                                            *
// * Contact www.norpa.eu if the plugin is required but missing *
// **************************************************************
 
{$I i2dxEML}
 
// Ti2dxEMLEMLPriority = (emlpLowest, emlpLow, emlpNormal, emlpHigh, emlpHighest);
 
var
  sFileName: String;
 
  sId: String;
  sFrom: String;
  sTo: String;
  sCC: String;
  sHeaders: String;
  sSubject: String;
  sBody: String;
  sReturnReceipt: String;
  sAttachmentNames: String;
  sAttachmentFiles: String;
  dTimeStamp: TDateTime;
  ePriority: Ti2dxEMLEMLPriority;
  sPriority: String;
 
begin
  sFileName := i2dInputBox('Filename', 'Please enter EML-filename:', '');
  if sFileName = '' then
    i2dCancelProcess('No filename entered');
 
  // Extract all e-mail data
  i2dxEMLGetDataFromEMLFile(sFileName, sId, sFrom, sTo, sCC, sReturnReceipt, sSubject,
                            sHeaders, sBody, sAttachmentNames, sAttachmentFiles, dTimeStamp, ePriority);
 
  try
    i2dDebugOut('Id : ' + sId);
    i2dDebugOut('From : ' + sFrom);
    i2dDebugOut('_To : ' + sTo);
    i2dDebugOut('CC : ' + sCC);
    i2dDebugOut('ReturnReceipt : ' + sReturnReceipt);
    i2dDebugOut('Subject : ' + sSubject);
    i2dDebugOut('Headers : ' + i2dReplaceString(sHeaders, #13#10, '|', [rfReplaceAll]));
    i2dDebugOut('Body : ' + i2dReplaceString(sBody, #13#10, '|', [rfReplaceAll]));
    i2dDebugOut('AttachmentNames: ' + sAttachmentNames);
    i2dDebugOut('AttachmentFiles: ' + sAttachmentFiles);
    i2dDebugOut('TimeStamp : ' + DateTimeToStr(dTimeStamp));
 
    case ePriority of
      emlpLowest: sPriority := 'Lowest';
      emlpLow: sPriority := 'Low';
      emlpNormal: sPriority := 'Normal';
      emlpHigh: sPriority := 'High';
      emlpHighest: sPriority := 'Highest';
    end;
 
    i2dDebugOut('Priority : ' + sPriority);
  finally
    // IMPORTANT: cleanup the allocated ressources
    i2dxEMLCleanupAttachmentFiles(sAttachmentFiles);
  end;
end.

Atom

powered by Nibbleblog