无法使用 Chrome 发送带有 PDF 附件的电子邮件

问题描述

我有一个用户输入信息并可以选择上传文档的表单。一旦他们填写了表格并单击提交按钮,就会向指定的收件人发送一封电子邮件。这在 IE 和 Firefox 中工作正常(无论用户上传/不上传文档)。

但是,当用户上传文档并在 chrome 中提交表单时,似乎 chrome 尝试处理该文档然后崩溃。

这是我检查用户是否已将文档上传到表单并将其存储在临时文件夹中的逻辑:

<cfif isdefined("FORM.file_type_attachment") AND Len(FORM.file_type_attachment) GT 0>
   <!--- first actually upload the file --->
   <cffile action="upload"
             filefield="file_type_attachment"
             destination="destination of file"
             nameconflict="Makeunique">
    <!--- Now create a temporary holder for the attachment later on --->
    <cfset attachment_local_file_1 = "file location">
</cfif>

<!--- Attaches attachment to email. --->
<cfsilent>
    <!--- Note that I used the <CFSILENT> tag,this will kill the white space in this area so your email is not cluttered with white space. --->
    <cfif isdefined("FORM.file_type_attachment") AND Len(FORM.file_type_attachment) GT 0>
        <cfmailparam file="#attachment_local_file_1#">
    </cfif>
</cfsilent> 

Update5:我可以毫无问题地发送某些文件。但是,当用户尝试通过电子邮件发送 pdf 文件时,Chrome 无法处理并且会填充错误通知用户发生了错误。在开发工具上,我看到以下内容

This is what I have done so far. This works fine if a

以下代码是我尝试允许用户附加文档的方法。处理 PDF 时是否有不同的方法?任何帮助将不胜感激。

        var sendForm = function(event) {
            event.preventDefault();
            var url = 'marcomrequestSent.cfm';
            document.getElementById('smbt').disabled = true;
            var form = event.target;
            var formData = new FormData(form);
            var xhr = new XMLHttpRequest();
            xhr.open('POST',url,true);
            //xhr.setRequestHeader('Content-type',undefined);
            xhr.onload = function(e) { 
                if(xhr.status == 200) {
                    //open the modal once the form passes validation
                    var m = modal.open({content: "<div class='modal-content'><div class='modal-header'><h4 class='modal-title' style='color: #9EC630 !important; font-size:28px; text-align:center;'>Request Sent</h4><button style='border:none;' id='closex' type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true' style='color:black'>x</span></button></div><br /><div class='modal-body'>" + "<p style='font-size:16px'>To return to the Marketing page,please click <a href='marketing.cfm'>here</a>."});             
                    if(m == true) {
                        return m;
                    } 
                    console.log('Form data (including any attachment) has been uploaded successfully.'); 
                }
                else {
                    if(xhr.status == 500){
                        alert("We seem to have encountered a problem. Please contact IT.");
                    }
                }
            };
            xhr.onerror = function(e) { 
                alert("We seem to have encountered a problem. Please contact IT."); 
            };
            xhr.send(formData);
        };

        document.getElementById('marcom_request_form').addEventListener('submit',sendForm);

有没有办法让用户发送pdf?需要帮助

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)