Skip to content
Snippets Groups Projects
Commit 5a84ecde authored by S.Listl's avatar S.Listl
Browse files

BulkMail preset subject from eml

parent d7df21d8
No related branches found
No related tags found
No related merge requests found
......@@ -174,6 +174,7 @@
<dbRecordFieldMapping>
<name>STATUS.value</name>
<recordfield>BULKMAILRECIPIENT.STATUS</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>ORGANISATION_ID.value</name>
......
import("KeywordRegistry_basic");
import("system.result");
result.string("BulkMailSentStatus"); //TODO: keyword registry
\ No newline at end of file
result.string($KeywordRegistry.bulkMailRecipientStatus());
\ No newline at end of file
......@@ -15,7 +15,7 @@
</entityField>
<entityField>
<name>TESTING_CONTACT_ID</name>
<title>Testing contact</title>
<title>Contact</title>
<consumer>Contacts</consumer>
<linkedContext>AnyContact</linkedContext>
<valueProcess>%aditoprj%/entity/BulkMailTesting_entity/entityfields/testing_contact_id/valueProcess.js</valueProcess>
......
......@@ -31,6 +31,7 @@
<entityField>
<name>SUBJECT</name>
<title>Subject</title>
<valueProcess>%aditoprj%/entity/BulkMail_entity/entityfields/subject/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>DESCRIPTION</name>
......@@ -167,7 +168,7 @@
</entityConsumer>
<entityField>
<name>TESTING_CONTACT_ID</name>
<title>Testing contact</title>
<title>Contact</title>
<consumer>Contacts</consumer>
<linkedContext>AnyContact</linkedContext>
</entityField>
......
import("system.result");
import("Email_lib");
import("Document_lib");
import("DocumentTemplate_lib");
import("system.neon");
import("system.vars");
if (vars.get("$this.value") == null && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
{
var upload = vars.get("$field.BINDATA");
var template;
if (upload)
{
var binData = DocumentUtil.getBindataFromUpload(upload);
var filename = DocumentUtil.getFilenameFromUpload(upload);
var type = DocumentUtil.getFileExtensionFromUpload(filename);
if (DocumentTemplate.types.fromFileExtension(type) == DocumentTemplate.types.EML)
result.string(Email.fromRFC(binData).subject);
}
}
\ No newline at end of file
......@@ -8,7 +8,8 @@ import("KeywordRegistry_basic");
var template = DocumentTemplate.loadTemplate(vars.get("$field.DOCUMENT_TEMPLATE"));
var contactId = vars.get("$param.ContactId_param");
var content = template.getReplacedContentByContactId(contactId, true);
neon.download(content, template.filename);
if (template.type)
neon.download(content, template.filename);
var links = [];
if (contactId)
......
......@@ -342,17 +342,14 @@ TemplateHelper._getReplacementsByContactIds = function (pTemplate, pContactIds)
*/
TemplateHelper._getReplacedEML = function (pTemplate, pReplacements, pGetEmail)
{
var mailData = mail.parseRFC(util.decodeBase64String(pTemplate.content));
var email;
var body = TemplateHelper._replaceText(mailData[mail.MAIL_HTMLTEXT], pReplacements);
if (pGetEmail)
{
var sender = TemplateHelper._replaceText(mailData[mail.MAIL_SENDER], pReplacements);
var subject = TemplateHelper._replaceText(mailData[mail.MAIL_SUBJECT], pReplacements);
email = new Email(null, sender, subject, body);
}
else
email = body;
var email = Email.fromRFC(pTemplate.content);
email.body = TemplateHelper._replaceText(email.body, pReplacements);
if (!pGetEmail)
return email.body;
email.sender = TemplateHelper._replaceText(email.sender, pReplacements);
email.subject = TemplateHelper._replaceText(email.subject, pReplacements);
return email;
}
......
......@@ -75,6 +75,19 @@ function Email (pToRecipients, pSender, pSubject, pBody, pCcRecipients, pBccReci
this.bccRecipients = pBccRecipients || [];
}
/**
* makes an Email object from a RFC mail (base64 encoded)
*/
Email.fromRFC = function (pBase64RFC)
{
var mailData = mail.parseRFC(util.decodeBase64String(pBase64RFC));
var body = mailData[mail.MAIL_HTMLTEXT];
var sender = mailData[mail.MAIL_SENDER];
var subject = mailData[mail.MAIL_SUBJECT];
return new Email(null, sender, subject, body);
}
/**
* loads a document template into the mail body
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment