Hi Aida,
In the document definition properties, under export destinations, add an export of type 'Custom export(script)' and enter the following.
try
{
string exportPath = @"C:\ExportFC\";
IExportImageSavingOptions options = FCTools.NewImageSavingOptions();
ExternalExports.Export export = new ExternalExports.Export();
int bid = Document.Batch.Id;
export.exportToTxt(bid, Document, exportPath);
}
catch (System.Exception e)
{
Processing.ReportError("Error: " + e.Message);
}
On the project setup station, click project->properties-> workflow tab.
Add a new stage of type user type just after the export stage.
Create a script of type batch processing and paste the following..
using System;
using System.Net;
using System.Net.Mail;
using System.IO;
using System.Collections.Generic;
string senderEmail = Batch.Properties.Get("fc_Predefined:EmailSender");
string senderEmailAbs = senderEmail.Split('<','>')[1];
int bid = Batch.Id;
string path = @"C:\ExportFC\"+bid.ToString();
string attFile = path+@"\"+"Batch"+bid+@".csv";
string sourceFolder = path;
string destinationFile = attFile;
// Specify wildcard search to match CSV files that will be combined
string[] filePaths = Directory.GetFiles(sourceFolder, @"*.csv");
StreamWriter fileDest = new StreamWriter(destinationFile, true);
int i;
for (i = 0; i < filePaths.Length; i++)
{
string file = filePaths[i];
string[] lines = File.ReadAllLines(file);
List<String> llines = new List<string>();
foreach (string ln in lines)
{
llines.Add(ln);
}
if (i > 0)
{
// lines = lines.Skip(1).ToArray(); // Skip header row for all but first file
// lines = lines.Skip(1).ToArray();
llines.RemoveAt(0);
}
foreach (string line in llines)
{
fileDest.WriteLine(line);
}
}
fileDest.Close();
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("sender@gmail.com");
mail.To.Add(senderEmailAbs);
mail.Subject = "CSV output for Batch#- " + bid;
mail.Body = "Please check the attachment!";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(attFile);
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("receiver@gmail.com", "enterpwd");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
You would need to download the customexport zip file from https://knowledgebase.abbyy.com/article/1266
and update your project with the ExternalExport.dll. I added it in the document definition properties->.net references-> add.
You need to create an import profile of type email and enter the servername and port and under settings, the email login and password, whether or not to use SSL.
That's pretty much it.
Hope you find it useful!