diff --git a/entity/BulkMail_entity/BulkMail_entity.aod b/entity/BulkMail_entity/BulkMail_entity.aod
index 0323f662f69bcea6afdd54266099f641a4bd8627..f6c1bd93b26397f5b8b1fd61f72ec82f5e871fc2 100644
--- a/entity/BulkMail_entity/BulkMail_entity.aod
+++ b/entity/BulkMail_entity/BulkMail_entity.aod
@@ -45,6 +45,9 @@
       <consumer>Templates</consumer>
       <mandatory v="false" />
       <onValueChange>%aditoprj%/entity/BulkMail_entity/entityfields/documenttemplate_id/onValueChange.js</onValueChange>
+      <onValueChangeTypes>
+        <element>MASK</element>
+      </onValueChangeTypes>
     </entityField>
     <entityConsumer>
       <name>Recipients</name>
@@ -114,6 +117,10 @@
       <name>bindata</name>
       <contentType>FILE</contentType>
       <stateProcess>%aditoprj%/entity/BulkMail_entity/entityfields/bindata/stateProcess.js</stateProcess>
+      <onValueChange>%aditoprj%/entity/BulkMail_entity/entityfields/bindata/onValueChange.js</onValueChange>
+      <onValueChangeTypes>
+        <element>MASK</element>
+      </onValueChangeTypes>
       <onValidation>%aditoprj%/entity/BulkMail_entity/entityfields/bindata/onValidation.js</onValidation>
     </entityField>
     <entityFieldGroup>
@@ -130,7 +137,9 @@
     <entityField>
       <name>content</name>
       <title>Content</title>
+      <contentType>HTML</contentType>
       <contentTypeProcess>%aditoprj%/entity/BulkMail_entity/entityfields/content/contentTypeProcess.js</contentTypeProcess>
+      <state>EDITABLE</state>
       <stateProcess>%aditoprj%/entity/BulkMail_entity/entityfields/content/stateProcess.js</stateProcess>
       <valueProcess>%aditoprj%/entity/BulkMail_entity/entityfields/content/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/BulkMail_entity/entityfields/content/displayValueProcess.js</displayValueProcess>
@@ -241,7 +250,7 @@
     <entityField>
       <name>preview</name>
       <title>Preview</title>
-      <contentTypeProcess>%aditoprj%/entity/BulkMail_entity/entityfields/preview/contentTypeProcess.js</contentTypeProcess>
+      <contentType>HTML</contentType>
       <valueProcess>%aditoprj%/entity/BulkMail_entity/entityfields/preview/valueProcess.js</valueProcess>
     </entityField>
   </entityFields>
diff --git a/entity/BulkMail_entity/entityfields/bindata/onValueChange.js b/entity/BulkMail_entity/entityfields/bindata/onValueChange.js
new file mode 100644
index 0000000000000000000000000000000000000000..5e84ced62afd83bf5d0b80855cffca4665874031
--- /dev/null
+++ b/entity/BulkMail_entity/entityfields/bindata/onValueChange.js
@@ -0,0 +1,13 @@
+import("system.logging");
+import("DocumentTemplate_lib");
+import("system.neon");
+import("system.vars");
+
+// note: could not use only the valueProcess from $field.content because then it refreshed $field.content just before save.
+// --> only set in $field.content.valueProcess if $field.content is null and set it from here only if MASK triggered change
+if(vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
+{ 
+    [content, type] = DocumentTemplateUtils.getTemplateContent(vars.get("$field.DOCUMENTTEMPLATE_ID"), new FileUpload(vars.get("$local.value")));
+    vars.set("$context.currentTemplateType", type)
+    vars.set("$field.content", content)
+}
diff --git a/entity/BulkMail_entity/entityfields/bindata/stateProcess.js b/entity/BulkMail_entity/entityfields/bindata/stateProcess.js
index aabc8ec3426af49c8dfc92204b26d794a914acc5..aeb23379eede28c20e47793bb4426f9ca2dfbd59 100644
--- a/entity/BulkMail_entity/entityfields/bindata/stateProcess.js
+++ b/entity/BulkMail_entity/entityfields/bindata/stateProcess.js
@@ -4,5 +4,5 @@ import("system.neon");
 
 var state = neon.COMPONENTSTATE_EDITABLE;
 if (vars.get("$field.DOCUMENTTEMPLATE_ID"))
-    state = neon.COMPONENTSTATE_READONLY;
+    state = neon.COMPONENTSTATE_INVISIBLE;
 result.string(state);
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/content/contentTypeProcess.js b/entity/BulkMail_entity/entityfields/content/contentTypeProcess.js
index 3213243e36f55cfa8df7f82383779871968e5e69..af8f592df38c73cf97104d70f983512dd059c129 100644
--- a/entity/BulkMail_entity/entityfields/content/contentTypeProcess.js
+++ b/entity/BulkMail_entity/entityfields/content/contentTypeProcess.js
@@ -1,21 +1,10 @@
+import("system.neon");
 import("Bulkmail_lib");
 import("system.result");
 import("Document_lib");
 import("system.vars");
 import("DocumentTemplate_lib");
-/*
-var mimeType = DocumentUtil.getMimeTypeFromUpload(vars.get("$field.bindata"));
-var type;
-if (mimeType)
-{
-    type = DocumentTemplate.types.fromMimeType(mimeType);
-}
-else
-{
-    let template = BulkMailUtils.getBulkMailTemplate(vars.get("$field.BULKMAILID"), vars.get("$field.DOCUMENTTEMPLATE_ID"), false);
-    type = template.type;
-}
-*/
-result.string(vars.get("$context.currentTemplateType") == DocumentTemplate.types.TXT
+
+result.string(vars.get("$context.currentTemplateType") == DocumentTemplate.types.TXT// && vars.get("$sys.recordstate") != neon.OPERATINGSTATE_VIEW
     ? "LONG_TEXT" 
     : "HTML");
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/content/displayValueProcess.js b/entity/BulkMail_entity/entityfields/content/displayValueProcess.js
index 792b6ffb622b127dedf6dc06b47567bdf60db289..a2ecf36da764cb125c10b42071e1fb4786ae0d54 100644
--- a/entity/BulkMail_entity/entityfields/content/displayValueProcess.js
+++ b/entity/BulkMail_entity/entityfields/content/displayValueProcess.js
@@ -1,3 +1,4 @@
+import("system.logging");
 import("Bulkmail_lib");
 import("system.text");
 import("Employee_lib");
@@ -14,5 +15,9 @@ if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
     
     var contactId = EmployeeUtils.getCurrentContactId();
     var preview = template.getReplacedContentByContactId(contactId, false, true);
-    result.string(preview);
+    
+    if (vars.get("$context.currentTemplateType") == DocumentTemplate.types.TXT)
+        result.string(text.text2html(preview, false));
+    else
+        result.string(preview);
 }
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/content/stateProcess.js b/entity/BulkMail_entity/entityfields/content/stateProcess.js
index 1674111c065d736b00d05453dd1ca9c3201b2910..fa18329824150cafe345fa394738e1780b3b9822 100644
--- a/entity/BulkMail_entity/entityfields/content/stateProcess.js
+++ b/entity/BulkMail_entity/entityfields/content/stateProcess.js
@@ -3,7 +3,9 @@ import("system.vars");
 import("system.neon");
 import("DocumentTemplate_lib");
 
-if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_VIEW && vars.get("$context.currentTemplateType") == DocumentTemplate.types.EML)
+if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_VIEW && 
+    (vars.get("$context.currentTemplateType") == DocumentTemplate.types.EML
+      || vars.get("$context.currentTemplateType") == DocumentTemplate.types.HTML)) // TODO: invisible for html as there are problems with images which are removed by the html-editor
 {
     result.string(neon.COMPONENTSTATE_INVISIBLE);
 }
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/content/valueProcess.js b/entity/BulkMail_entity/entityfields/content/valueProcess.js
index 9b8c05e63037cd20157a5449c090f1d64902886a..ec9c8eda42491c7062914f777ed079808fc1a7c2 100644
--- a/entity/BulkMail_entity/entityfields/content/valueProcess.js
+++ b/entity/BulkMail_entity/entityfields/content/valueProcess.js
@@ -6,19 +6,14 @@ import("system.db");
 import("DocumentTemplate_lib");
 import("Bulkmail_lib");
 
-if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
+if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && vars.get("$this.value") == null)
 {
-    var upload = new FileUpload(vars.get("$field.bindata"));
-    var template;
-
-    if (upload.bindata)
-        template = DocumentTemplate.fromUpload(upload);
-    else
-        template = BulkMailUtils.getBulkMailTemplate(vars.get("$field.BULKMAILID"), vars.get("$field.DOCUMENTTEMPLATE_ID"), false);
-    
-    vars.set("$context.currentTemplateType", template.type);
-    
-    var content = template.getReplacedContent({});
-    if (content)
-        result.string(content);
+    [content, type] = DocumentTemplateUtils.getTemplateContent(vars.get("$field.DOCUMENTTEMPLATE_ID"), new FileUpload(vars.get("$field.bindata")));
+    vars.set("$context.currentTemplateType", type);
+    result.string(content);
+} 
+else if (!vars.get("$field.DOCUMENTTEMPLATE_ID"))
+{
+    result.string("");
+    vars.set("$context.currentTemplateType", "");
 }
\ No newline at end of file
diff --git a/entity/BulkMail_entity/entityfields/documenttemplate_id/onValueChange.js b/entity/BulkMail_entity/entityfields/documenttemplate_id/onValueChange.js
index f91b0bf6be58779dd32bd3da51b5eb25e1713072..a088775e18847d0224cd3d865bea207bd6e5f4fa 100644
--- a/entity/BulkMail_entity/entityfields/documenttemplate_id/onValueChange.js
+++ b/entity/BulkMail_entity/entityfields/documenttemplate_id/onValueChange.js
@@ -7,6 +7,13 @@ import("Entity_lib");
 
 if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
 {
+    // note: could not use only the valueProcess from $field.content because then it refreshed $field.content just before save.
+    // --> only set in $field.content.valueProcess if $field.content is null and set it from here only if MASK triggered change
+    [content, type] = DocumentTemplateUtils.getTemplateContent(vars.get("$local.value"), new FileUpload(vars.get("$field.bindata")));
+    vars.set("$context.currentTemplateType", type);
+    vars.set("$field.content", content)
+    
+    // TODO: load subject without loadTemplate again... maybe return with getTemplateContent() above?
     var templateId = vars.get("local.value");
     var template = DocumentTemplate.loadTemplate(templateId, undefined, false);
     if (template.type == DocumentTemplate.types.EML)
diff --git a/entity/BulkMail_entity/entityfields/preview/contentTypeProcess.js b/entity/BulkMail_entity/entityfields/preview/contentTypeProcess.js
deleted file mode 100644
index 6d7fd7c7c5bf1ac20c2f1daa5566031c39b9c3d0..0000000000000000000000000000000000000000
--- a/entity/BulkMail_entity/entityfields/preview/contentTypeProcess.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import("system.vars");
-import("system.result");
-import("DocumentTemplate_lib");
-
-result.string(vars.get("$context.currentTemplateType") == DocumentTemplate.types.TXT
-    ? "LONG_TEXT" 
-    : "HTML");
\ No newline at end of file
diff --git a/entity/DocumentTemplate_entity/entityfields/bindata/onValueChange.js b/entity/DocumentTemplate_entity/entityfields/bindata/onValueChange.js
index 50fc4cc09f11cfed46114a722a337a615b758c87..4634a56420c3aefc9e92c7be8e6d308aad59628c 100644
--- a/entity/DocumentTemplate_entity/entityfields/bindata/onValueChange.js
+++ b/entity/DocumentTemplate_entity/entityfields/bindata/onValueChange.js
@@ -6,5 +6,7 @@ import("system.vars");
 // --> only set in $field.Content.valueProcess if $field.Content is null and set it from here only if MASK triggered change
 if((vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT || vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW))
 {
-    vars.set("$field.Content", DocumentTemplateUtils.getTemplateContent(vars.get("$field.DOCUMENTTEMPLATEID"), new FileUpload(vars.get("$local.value"))))
+    [content, type] = DocumentTemplateUtils.getTemplateContent(vars.get("$field.DOCUMENTTEMPLATEID"), new FileUpload(vars.get("$local.value")));
+    vars.set("$context.currentTemplateType", type);
+    vars.set("$field.content", content)
 }
diff --git a/entity/DocumentTemplate_entity/entityfields/content/valueProcess.js b/entity/DocumentTemplate_entity/entityfields/content/valueProcess.js
index 2a136f8c775cc95a7132f41154c1e2a408830507..5158388e7c2042154859ba89649d91e398eb12da 100644
--- a/entity/DocumentTemplate_entity/entityfields/content/valueProcess.js
+++ b/entity/DocumentTemplate_entity/entityfields/content/valueProcess.js
@@ -6,5 +6,7 @@ import("system.vars");
 
 if((vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT || vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) && vars.get("$this.value") == null)
 {
-    result.string(DocumentTemplateUtils.getTemplateContent(vars.get("$field.DOCUMENTTEMPLATEID"), new FileUpload(vars.get("$field.BINDATA"))))
+    [content, type] = DocumentTemplateUtils.getTemplateContent(vars.get("$field.DOCUMENTTEMPLATEID"), new FileUpload(vars.get("$field.BINDATA")));
+    vars.set("$context.currentTemplateType", type);
+    result.string(content);
 }
diff --git a/process/DocumentTemplate_lib/process.js b/process/DocumentTemplate_lib/process.js
index 02d1352aca604c11488f920313d01e017e080901..d6b04b6584727ab50cf9eb3791ba9683d4b4460a 100644
--- a/process/DocumentTemplate_lib/process.js
+++ b/process/DocumentTemplate_lib/process.js
@@ -69,7 +69,7 @@ DocumentTemplate.prototype.toString = function (pWithSubtemplates)
 }
 
 DocumentTemplate.prototype._resolveEmbeddedTemplate = function ()
-{    
+{
     // currently we support only txt and html as others would need special caution.
     if (this.content != null && (this.type == DocumentTemplate.types.TXT || this.type == DocumentTemplate.types.HTML))
     {
@@ -88,7 +88,7 @@ DocumentTemplate.prototype._resolveEmbeddedTemplate = function ()
         
         if (this.type == DocumentTemplate.types.HTML)
         {
-            templates.concat(db.table(SqlCondition.begin()
+            templates = templates.concat(db.table(SqlCondition.begin()
                         .andPrepare("DOCUMENTTEMPLATE.KIND", $KeywordRegistry.documentTemplateType$textModular())
                         .andPrepare("DOCUMENTTEMPLATE.CLASSIFICATION", $KeywordRegistry.documentTemplateTypeCategory$htmlTemplate())
                         .buildSql("select DOCUMENTTEMPLATEID, REPLACEMENTNAME from DOCUMENTTEMPLATE")));
@@ -287,10 +287,27 @@ DocumentTemplate.prototype.getReplacedContent = function (pReplacements, pEncode
 {
     // if there exists a _subtemplatedContent we use it because then I assume that the replacements are already based on content + subtemplates
     var content = this._getTemplatedContent(true);
-        
+    
     switch (this.type)
     {
+        case DocumentTemplate.types.EML:
+            let emlContent
+            if (pEmlOnlyBody)
+            {
+                // get only body and treat it as html (next case)
+                var email = Email.fromRFC(content);
+                content = util.encodeBase64String(email.body);
+            }
+            else
+            {
+                emlContent = util.decodeBase64String(content);
+                emlContent = TemplateHelper._replaceText(emlContent, pReplacements, TemplateHelper._getSpecialRegexp(this));
+                if (pEncoded)
+                    emlContent = util.encodeBase64String(emlContent);
+                return emlContent;
+            }
         case DocumentTemplate.types.HTML:
+            // replaces ä, ö, ü, ... with html escape signs
             for (let i in pReplacements)
                 pReplacements[i] = text.text2html(pReplacements[i], false);
         case DocumentTemplate.types.TXT:
@@ -299,19 +316,6 @@ DocumentTemplate.prototype.getReplacedContent = function (pReplacements, pEncode
             if (pEncoded)
                 encodedContent = util.encodeBase64String(encodedContent);
             return encodedContent;
-        case DocumentTemplate.types.EML:
-            let emlContent
-            if (pEmlOnlyBody)
-            {
-                var email = Email.fromRFC(content)
-                emlContent = email.body
-            }
-            else
-                emlContent = util.decodeBase64String(content);
-            emlContent = TemplateHelper._replaceText(emlContent, pReplacements, TemplateHelper._getSpecialRegexp(this));
-            if (pEncoded)
-                emlContent = util.encodeBase64String(emlContent);
-            return emlContent;
         case DocumentTemplate.types.ODT:
             return TemplateHelper._getReplacedODT(this, pReplacements);
         case DocumentTemplate.types.DOCX:
@@ -479,7 +483,6 @@ TemplateHelper._getRequiredPlaceholders = function (pTemplate)
         {
             return foundPlaceholders.indexOf(pPlaceholder.placeholderName) != -1;
         });
-        logging.log(JSON.stringify([placeholders], null, "\t"))
         return placeholders;
     }
     
@@ -770,10 +773,11 @@ DocumentTemplateUtils.updateTemplateData = function (pTemplateId, pFileUpload, p
  * @param {String} pTemplateId the id of the template
  * @param {FileUpload} pFileUpload upload object
  * 
- * @return {String} content or ""
+ * @return {String[]} [content, type] or ["", null]
  */
 DocumentTemplateUtils.getTemplateContent = function (pTemplateId, pFileUpload)
 {
+    logging.log(JSON.stringify([pTemplateId, pFileUpload.isFilled()], null, "\t"))
     var type;
     var bindata;
     
@@ -798,12 +802,14 @@ DocumentTemplateUtils.getTemplateContent = function (pTemplateId, pFileUpload)
         }
     }
     
-    if (type == DocumentTemplate.types.HTML || type == DocumentTemplate.types.TXT)
+    logging.log("asd" + JSON.stringify([type], null, "\t"))
+    
+    if (type == DocumentTemplate.types.HTML || type == DocumentTemplate.types.TXT || type == DocumentTemplate.types.EML)
     {
-        return util.decodeBase64String(bindata);
+        return [util.decodeBase64String(bindata), type];
     }
     
-    return "";
+    return ["", null];
 }
 
 /**