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
Admin message
Gitlab Maintenance 28.03.2025 | 20:00 - 23:00 MEZ
Show more breadcrumbs
xrm
basic
Commits
4499939b
Commit
4499939b
authored
5 years ago
by
Johannes Goderbauer
Browse files
Options
Downloads
Patches
Plain Diff
Mail-writing: switch from mailto to downloading
parent
477d7d06
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/Email_lib/process.js
+56
-10
56 additions, 10 deletions
process/Email_lib/process.js
with
56 additions
and
10 deletions
process/Email_lib/process.js
+
56
−
10
View file @
4499939b
import
(
"
system.translate
"
);
import
(
"
system.text
"
);
import
(
"
system.db
"
);
import
(
"
system.util
"
);
import
(
"
Communication_lib
"
);
import
(
"
system.neon
"
);
import
(
"
system.mail
"
);
function
EmailUtils
()
{}
...
...
@@ -14,7 +14,8 @@ EmailUtils.openMailTemplate = function (pToRecipients, pContactId, pTemplateId)
email
.
setSender
(
pContactId
);
if
(
pTemplateId
)
email
.
setTemplate
(
pTemplateId
);
email
.
openMail
();
email
.
downloadEML
();
}
EmailUtils
.
openNewMail
=
function
(
pToContactId
)
...
...
@@ -58,12 +59,13 @@ function Email (pToRecipients, pSender, pSubject, pBody, pCcRecipients, pBccReci
Email
.
prototype
.
setTemplate
=
function
(
pTemplateId
)
{
var
alias
=
"
_____SYSTEMALIAS
"
;
var
binaryId
=
db
.
cell
(
SqlCondition
.
begin
(
alias
)
.
andPrepare
(
"
ASYS_BINARIES.ROW_ID
"
,
pTemplateId
)
.
buildSql
(
"
select ID from ASYS_BINARIES
"
,
"
1=2
"
),
alias
)
;
var
templateDocument
=
db
.
getBinaryMetadata
(
"
DOCUMENTTEMPLATE
"
,
"
DOCUMENT
"
,
pTemplateId
,
false
,
alias
,
null
);
if
(
!
templateDocument
[
0
]
)
return
null
;
var
binaryId
=
templateDocument
[
0
][
db
.
BINARY_ID
]
;
if
(
binaryId
)
this
.
body
=
text
.
html2text
(
util
.
decodeBase64String
(
db
.
getBinaryContent
(
binaryId
,
alias
)));
this
.
body
=
util
.
decodeBase64String
(
db
.
getBinaryContent
(
binaryId
,
alias
));
return
null
;
}
/**
...
...
@@ -96,17 +98,61 @@ Email.prototype.getMailtoUrl = function ()
url
.
push
(
"
subject=
"
+
this
.
subject
);
if
(
this
.
body
)
url
.
push
(
"
body=
"
+
this
.
body
);
url
.
push
(
"
body=
"
+
text
.
html2text
(
this
.
body
)
)
;
url
=
"
mailto:?
"
+
url
.
join
(
"
&
"
);
return
encodeURI
(
url
);
}
/**
* generates a eml-element from the email object
*/
Email
.
prototype
.
getRFCmail
=
function
()
{
var
ENCODING
=
"
UTF8
"
;
var
mailId
=
mail
.
newMail
();
if
(
this
.
toRecipients
.
length
)
mail
.
addRecipients
(
mailId
,
mail
.
RECIPIENT_TO
,
this
.
toRecipients
);
if
(
this
.
ccRecipients
.
length
)
mail
.
addRecipients
(
mailId
,
mail
.
RECIPIENT_CC
,
this
.
ccRecipients
);
if
(
this
.
bccRecipients
.
length
)
mail
.
addRecipients
(
mailId
,
mail
.
RECIPIENT_BCC
,
this
.
bccRecipients
);
if
(
this
.
subject
)
mail
.
setSubject
(
mailId
,
this
.
subject
,
ENCODING
);
if
(
this
.
body
)
mail
.
addText
(
mailId
,
this
.
body
,
"
text/html
"
,
ENCODING
,
null
);
//"X-Unsent" is a very badly, non-standardised header to gently ask the mail client that the mail should open in a compose-mode
//this is mainly done for Microsoft Outlook for Windows.
//Thunderbird has a dinosaur-request (it's from the year 2002) to also support this: https://bugzilla.mozilla.org/show_bug.cgi?id=166541
mail
.
addHeader
(
mailId
,
"
X-Unsent
"
,
"
1
"
);
//accoding to this entry: https://stackoverflow.com/questions/11330628/os-x-mail-open-eml-files-in-compose-mode/33224913
//something similar exists for OS X Mail
//X-Uniform-Type-Identifier: com.apple.mail-draft
//this could be added later if needed
var
mailObj
=
mail
.
getCachedMail
(
mailId
);
return
mail
.
toRFC
(
mailObj
);
}
/**
* opens the email
*/
Email
.
prototype
.
openMail
=
function
()
{
neon
.
openUrl
(
this
.
getMailtoUrl
(),
false
);
}
\ No newline at end of file
}
Email
.
prototype
.
downloadEML
=
function
()
{
neon
.
download
(
util
.
encodeBase64String
(
this
.
getRFCmail
(),
null
),
(
this
.
subject
||
translate
.
text
(
"
Email Template
"
))
+
"
.eml
"
);
}
\ No newline at end of file
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