DocumentNo,
X_C_Invoice.Table_ID,
C_Invoice_ID,
C_BPartner_ID);
info.setCopies(copies);
ReportEngine re = new ReportEngine(getCtx(), format, query, info);
boolean printed = false;
if (p_EMailPDF)
{
String subject = mText.getMailHeader() + " - " + DocumentNo;
EMail email = client.createEMail(to.getEMail(), subject, null);
if (!email.isValid())
{
addLog (C_Invoice_ID, null, null,
DocumentNo + " @RequestActionEMailError@ Invalid EMail: " + to);
errors++;
continue;
}
mText.setUser(to); // Context
mText.setBPartner(C_BPartner_ID); // Context
mText.setPO(new MInvoice(getCtx(), C_Invoice_ID, get_TrxName()));
String message = mText.getMailText(true);
if (mText.isHtml())
email.setMessageHTML(subject, message);
else
{
email.setSubject (subject);
email.setMessageText (message);
}
//
File invoice = null;
if (!Ini.isClient())
invoice = new File(MInvoice.getPDFFileName(documentDir, C_Invoice_ID));
File attachment = re.getPDF(invoice);
log.fine(to + " - " + attachment);
email.addAttachment(attachment);
//
String msg = email.send();
MUserMail um = new MUserMail(mText, getAD_User_ID(), email);
um.save();
if (msg.equals(EMail.SENT_OK))
{
addLog (C_Invoice_ID, null, null,
DocumentNo + " @RequestActionEMailOK@ - " + to.getEMail());
count++;
printed = true;
}
else
{
addLog (C_Invoice_ID, null, null,
DocumentNo + " @RequestActionEMailError@ " + msg
+ " - " + to.getEMail());
errors++;
}
}
else
{
re.print();
count++;
printed = true;
}
// Print Confirm
if (printed)