如何在Chrome上的文件夹中打开电子邮件
有一个共享公用文件夹,用户可以使用它来上传共享文档。在共享资源中,部分用户上传了outlook邮件快捷方式,供大家共享。
当用户尝试在 chrome、IE 等上打开资源时,我试图让这封电子邮件在 Outlook 中打开。
这是可以实现的吗?
以下是保存在共享文件夹中的电子邮件示例:
电子邮件示例。
以下代码是我目前正在执行的操作,目的是让用户能够在浏览器上查看文件夹并打开和保存文档:
<!--- The following if statement checks if the url wants to be downloaded. If it does, it creates a downloadable link. --->
<cfif structKeyExists(URL, 'method') and URL.method eq 'download'>
<cfset file_name = URL.name />
<cfset path = URL.path />
<!--- The following if statements determine file type. --->
<cfif findNoCase('.doc', file_name) or findNoCase('.odt', file_name) or findNoCase('.rtf', file_name) >
<cfset file_type = 'application/msword' >
<cfelseif findNoCase('.pdf', file_name) >
<cfset file_type = 'application/pdf' >
<cfelseif findNoCase('.xls', file_name) or findNoCase('.xlt', file_name) or findNoCase('.csv', file_name)>
<cfset file_type = 'application/vnd.ms-excel' >
<cfelseif findNoCase('.tif', file_name) >
<cfset file_type = 'image' >
<cfelseif findNoCase('.jpg', file_name) >
<cfset file_type = 'image/jpeg' >
<cfelseif findNoCase('.url', file_name) or findNoCase('.lnk', file_name) >
<cfset file_type = 'text/uri-list' >
<cfelseif findNoCase('.msg', file_name) >
<cfset file_type = 'text/uri-list' >
</cfif>
<!--- The following statements creates a downloadable link of the file. This is done by using cfheader and cfcontent --->
<cfheader name="Content-Disposition" value="inline; filename=#file_name#">
<!---Check if file type is available. If available, show type. --->
<cfif isDefined("file_type") >
<cfcontent type="#file_type#" file="#path##file_name#">
<!--- If file type is not found, display file anyways. --->
<cfelse>
<cfcontent file="#path##file_name#">
</cfif>
<cfabort>
</cfif>
回答
描述<cfcontent>标签的文档指出,“以下标签可以强制大多数浏览器显示一个对话框,询问用户是否要使用文件名值指定的文件名保存由 cfcontent 标签指定的文件的内容。如果用户选择打开文件,大多数浏览器在相关应用程序中打开文件,而不是浏览器窗口。
<cfheader name="Content-Disposition" value="attachment; filename=filename.ext">
某些文件类型,例如 PDF 文档,不使用可执行代码,可以直接在大多数浏览器中显示。要请求浏览器直接显示文件,请使用类似于以下内容的 cfheader 标记:
<cfheader name="Content-Disposition" value="inline; filename=name.ext">"
你问题中的代码是这样的:
<cfheader name="Content-Disposition" value="inline; filename=#file_name#">
关键属性是值。您有“内联”,它要求浏览器直接显示文件。“附件”值将允许用户使用本地计算机上该类型文件的默认应用程序打开文件。