SOLVED Javascript created EML with attachment contains one more unwanted attachment, how to get rid of?

喜夏-厌秋 提交于 2020-01-25 07:52:20

问题


* SOLVED * solution to below problem was to add"--" in the end of the last boundary delimiter ----boundary_text_string**--**


I use below code to create MIME eml mail client side in javascript.

If I leave a "blank" line between Content-Type: text/html; charset="utf-8" and <html> then beside the attachment I add and want, there is another, unwanted one "Untitled attachment 01376.txt", that gets automatically added by magic to the mail. All other parts of the mail with subject and body text etc are as wanted. See pic "with line.jpg". As I can see in PSPad this strange file only contains hex "FFFE".

If I remove the line between Content-Type: text/html; charset="utf-8" and <html> then there is only the attachment that I want (no other one) but suddenly no body text. See pic "without line.jpg".

Code:

<textarea id="textbox_mailing" style="width: 600px; height: 600px; display:none;">
To: %%RECIPIENT%%
Subject: %%BETREFF%%
X-Unsent: 1
Content-Type: multipart/mixed; boundary=--boundary_text_string

----boundary_text_string
Content-Type: text/html; charset="utf-8"    

<html>
<head>
  <style>
      body, html, table 
      {
          font-family: Calibri
      }
      table 
      {
        border: 1px solid silver;
        padding: 2px;
      }
      thead, th 
      {
          text-align: left;
          border-bottom: 0.5px solid silver;
      }
      tbody td {
        text-align: left;
      }
  </style>
</head>
<body>
%%ANREDE%%,<br>
<br>
lore ipsum lore ipsum....<br>
<br>
%%ANGEBOTE_PENDING%%
<br>
%%SIGNATUR%% 
</body>
</html>
----boundary_text_string
Content-Type: application/pdf; name=example.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment

%%B64_STREAM%%

----boundary_text_string
</textarea>

This problem makes my life miserable for more than a week now, any help very much appreciated!

Thx a lot, BR Michael.

PS: please no general discussion why not serverside or why not using mail platforms.

Code with blank line

Code without blank line

来源:https://stackoverflow.com/questions/59870334/solved-javascript-created-eml-with-attachment-contains-one-more-unwanted-attachm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!