Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
5309a5d5
Commit
5309a5d5
authored
5 years ago
by
Johannes Hörmann
Browse files
Options
Downloads
Patches
Plain Diff
move bulkmail via template generation from DocumentTemplate to Email
parent
cde5f878
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
process/Bulkmail_lib/process.js
+1
-1
1 addition, 1 deletion
process/Bulkmail_lib/process.js
process/DocumentTemplate_lib/process.js
+2
-1
2 additions, 1 deletion
process/DocumentTemplate_lib/process.js
process/Email_lib/process.js
+37
-13
37 additions, 13 deletions
process/Email_lib/process.js
with
40 additions
and
15 deletions
process/Bulkmail_lib/process.js
+
1
−
1
View file @
5309a5d5
...
...
@@ -83,7 +83,7 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pTestRecipients)
var
successIds
=
[];
var
failedIds
=
[];
var
sentDate
=
vars
.
get
(
"
$sys.date
"
);
var
mails
=
template
.
getReplacedEmails
ByContactIds
(
contactIds
);
var
mails
=
Email
.
getReplaced
Bulk
Emails
(
template
,
contactIds
);
var
subjectTemplate
=
new
DocumentTemplate
(
subject
,
DocumentTemplate
.
types
.
PLAIN
);
var
subjects
=
subjectTemplate
.
getReplacedContentByContactIds
(
contactIds
);
...
...
This diff is collapsed.
Click to expand it.
process/DocumentTemplate_lib/process.js
+
2
−
1
View file @
5309a5d5
...
...
@@ -279,8 +279,9 @@ DocumentTemplate.getSelectedTemplate = function (pTemplateId, pDocumentUpload, p
* replace function for the type.
*
* @param {Object} pReplacements map, the structure is {placeholder : value}
* @param {
b
oolean} pEncoded if the replaced content should be base64 encoded
* @param {
B
oolean} pEncoded if the replaced content should be base64 encoded
* (doesn't affect odt/docx)
* @param {Boolean} {pEmlOnlyBody=false} if true for eml's only the body is parsed (e.g. for previews. Note that eml-bodies are not editable!)
*
* @return {String} the replaced content
*/
...
...
This diff is collapsed.
Click to expand it.
process/Email_lib/process.js
+
37
−
13
View file @
5309a5d5
...
...
@@ -69,14 +69,16 @@ EmailWritingUtils.getMailbridgeAddress = function ()
/**
* object for handling emails
*
*
@param {String} [pBody=null] if given, the body is set to this text
* @class
*/
function
Email
()
function
Email
(
pBody
)
{
if
(
pBody
==
undefined
)
pBody
=
null
;
this
.
sender
=
null
;
this
.
subject
=
null
;
this
.
body
=
null
;
this
.
body
=
pBody
;
this
.
toRecipients
=
[];
this
.
ccRecipients
=
[];
this
.
bccRecipients
=
[];
...
...
@@ -94,9 +96,8 @@ Email.fromRFC = function (pBase64RFC)
{
var
decoded
=
util
.
decodeBase64String
(
pBase64RFC
);
var
mailData
=
mail
.
parseRFC
(
decoded
);
var
newMail
=
new
Email
();
var
newMail
=
new
Email
(
mailData
[
mail
.
MAIL_HTMLTEXT
]
);
newMail
.
subject
=
mailData
[
mail
.
MAIL_SUBJECT
];
newMail
.
body
=
mailData
[
mail
.
MAIL_HTMLTEXT
];
newMail
.
emlFile
=
decoded
;
return
newMail
;
}
...
...
@@ -114,16 +115,39 @@ Email.fromTemplate = function (pTemplateId, pContactId, pBindata)
else
template
=
DocumentTemplate
.
loadTemplate
(
pTemplateId
);
if
(
template
.
type
==
DocumentTemplate
.
types
.
EML
)
{
return
Email
.
fromRFC
(
template
.
getReplacedContentByContactIds
([
pContactId
],
true
)[
pContactId
]);
}
else
return
Email
.
getReplacedBulkEmails
(
template
,
[
pContactId
])[
pContactId
];
}
/**
* Replaces the placeholders with data from the contacts and returns the resulting Emails.
* @param {DocumentTemplate} pTemplate a document template which is used for all mails
* @param {Array} pContactIds Contact ids of all recipients
*
* @return {Object} Object containing the contact ids as keys and the corresponding Email
* objects as values
*/
Email
.
getReplacedBulkEmails
=
function
(
pTemplate
,
pContactIds
)
{
var
emailObjects
=
{};
var
isEML
=
pTemplate
.
type
==
DocumentTemplate
.
types
.
EML
;
var
emailContents
=
pTemplate
.
getReplacedContentByContactIds
(
pContactIds
,
isEML
);
for
(
contactId
in
emailContents
)
{
var
email
=
new
Email
();
email
.
body
=
template
.
getReplacedContentByContactIds
([
pContactId
],
false
)[
pContactId
]
return
email
;
if
(
isEML
)
{
emailObjects
[
contactId
]
=
Email
.
fromRFC
(
emailContents
[
contactId
]);
}
else
{
// convert to HTML if needed
if
(
pTemplate
.
type
==
DocumentTemplate
.
types
.
TXT
||
pTemplate
.
type
==
DocumentTemplate
.
types
.
PLAIN
)
emailContents
[
contactId
]
=
text
.
text2html
(
emailContents
[
contactId
],
false
);
emailObjects
[
contactId
]
=
new
Email
(
emailContents
[
contactId
]);
}
}
return
emailObjects
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment