Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何将Outlook的拖放上载功能添加到Web表单?_Html_Upload_Outlook_Drag And Drop - Fatal编程技术网

Html 如何将Outlook的拖放上载功能添加到Web表单?

Html 如何将Outlook的拖放上载功能添加到Web表单?,html,upload,outlook,drag-and-drop,Html,Upload,Outlook,Drag And Drop,我正在寻找一种方法,允许用户以简单的方式将Outlook电子邮件上载到基于web的系统 我可以让它以手动方式为用户工作。他们可以将电子邮件从Outlook拖放到桌面,从而创建一个.msg文件。这非常好用,特别是如果电子邮件中有附件也存储在.msg文件中。然后可以使用传统的“输入类型=文件”html字段上载此文件 如果可能的话,我想简化这个过程。我见过一些网站,它们为硬盘上的文件提供了拖放上传功能 但是,我不确定是否存在允许直接从Outlook拖放的内容,该内容可以创建.msg文件或类似文件并处理

我正在寻找一种方法,允许用户以简单的方式将Outlook电子邮件上载到基于web的系统

我可以让它以手动方式为用户工作。他们可以将电子邮件从Outlook拖放到桌面,从而创建一个.msg文件。这非常好用,特别是如果电子邮件中有附件也存储在.msg文件中。然后可以使用传统的“输入类型=文件”html字段上载此文件

如果可能的话,我想简化这个过程。我见过一些网站,它们为硬盘上的文件提供了拖放上传功能

但是,我不确定是否存在允许直接从Outlook拖放的内容,该内容可以创建.msg文件或类似文件并处理文件上载。换句话说,这是一个解决方案,它省去了将电子邮件拖到桌面以创建用于上载的临时.msg文件的手动步骤


这可能吗?如果可能,如何实现?所有用户目前都使用Windows XP,并拥有Outlook 2007、IE6或更高版本以及Firefox。后端服务器正在为相关应用程序运行Java(我们的编程人员使用ASP.NET w/C进行web开发),尽管我认为任何解决方案都将主要基于Flash或JQuery之类的客户端技术。

但我不认为使用JQuery/JavaScript可以实现这一点-您可能有机会使用Flash之类的技术


作为替代方案,您是否可以创建一个简单的客户端应用程序,让他们可以在桌面上运行,这样他们就可以将消息拖到桌面上—这样,您就可以完全信任地运行,并执行您希望从该应用程序获取并上传文件的任何任务(这是我曾经使用过的一个文件扫描应用程序所使用的解决方案-我们有一个小窗口,用户可以将文件或电子邮件拖到该窗口上,开始上传到扫描存储。

您最终是如何实现这一点的?我正在寻找一个类似的解决方案,但找不到太多,因此最终在Outlook中使用了一个VBA宏,用户可以单击该宏。)选择邮件时打开。然后将邮件作为.msg复制到其临时文件夹,然后提交到HTML表单

我已经在下面添加了我从各种网络来源(包括这里-对不起,我不记得保存链接)拼凑起来的代码,以防任何人也想要这样做

我确信它可以被优化等等,因为我对VBA很陌生(昨天!),但现在它可以完成这项工作,尽管有人认为我想做的是检查IE窗口是否存在,并添加一个新的选项卡,而不是每次单击它时打开一个新的浏览器

' Function to maximize IE window
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2

Sub test()
 'the mail we want to process
Dim objItem As Outlook.MailItem
 'question for saving, use subject to save
Dim strPrompt As String, strname As String
 'variables for the replacement of illegal characters
Dim sreplace As String, mychar As Variant, strdate As String
 'put active mail in this object holder
Set objItem = Outlook.ActiveExplorer.Selection.Item(1)
 'check if it's an email ... need to take a closer look cause
 'gives an error when something else (contact, task) is selected
 'because objItem is defined as a mailitem and code errors out
 'saving does work, if you take care that a mailitem is selected
 'before executing this code
If objItem.Class = olMail Then
     'check on subject
    If objItem.Subject <> vbNullString Then
        strname = objItem.Subject
    Else
        strname = "No_Subject"
    End If
    strdate = objItem.ReceivedTime
     'define the character that will replace illegal characters
    sreplace = "_"
     'create an array to loop through illegal characters (saves lines)
    For Each mychar In Array(" ", "/", "\", ":", "?", Chr(34), "<", ">", "¦")
         'do the replacement for each character that's illegal
        strname = Replace(strname, mychar, sreplace)
        strdate = Replace(strdate, mychar, sreplace)
    Next mychar
     'Prompt the user for confirmation
    strPrompt = "Upload the email to CRM?"
    If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
        Dim location As String
        Dim tempPath As String
        tempPath = IIf(Environ$("tmp") <> "", Environ$("tmp"), Environ$("temp"))
        location = tempPath & "\" & strname & "-" & strdate & ".msg"
        objItem.SaveAs location, olMSG
        'upload to IE
        UploadFile "http://intranet/test.php", location, "msgupload"
    End If
End If
End Sub

'******************* upload - begin
'Upload file using input type=file
Sub UploadFile(DestURL As String, FileName As String, _
  Optional ByVal FieldName As String = "File")
  Dim sFormData As String, d As String
  'Boundary of fields.
  'Be sure this string is Not In the source file
  Const Boundary As String = "---------------------------0123456789012"
  'Get source file As a string.
  sFormData = GetFile(FileName)
  'Build source form with file contents
  d = "--" + Boundary + vbCrLf
  d = d + "Content-Disposition: form-data; name=""" + FieldName + """;"
  d = d + " filename=""" + FileName + """" + vbCrLf
  d = d + "Content-Type: application/upload" + vbCrLf + vbCrLf
  d = d + sFormData
  d = d + vbCrLf + "--" + Boundary + "--" + vbCrLf
  'Post the data To the destination URL
  IEPostStringRequest DestURL, d, Boundary
End Sub

'sends URL encoded form data To the URL using IE
Sub IEPostStringRequest(URL As String, FormData As String, Boundary As String)
  'Create InternetExplorer
  Dim WebBrowser: Set WebBrowser = CreateObject("InternetExplorer.Application")
  'You can uncoment Next line To see form results
  WebBrowser.Visible = True
  'Send the form data To URL As POST request
  Dim bFormData() As Byte
  ReDim bFormData(Len(FormData) - 1)
  bFormData = StrConv(FormData, vbFromUnicode)
  ' Submit message to intranet
  WebBrowser.Navigate2 URL, , , bFormData, "Content-Type: multipart/form-data; boundary=" + Boundary + vbCrLf
  ' Maximize window
  apiShowWindow WebBrowser.hwnd, SW_MAXIMIZE
End Sub

'read binary file As a string value
Function GetFile(FileName As String) As String
  Dim FileContents() As Byte, FileNumber As Integer
  ReDim FileContents(FileLen(FileName) - 1)
  FileNumber = FreeFile
  Open FileName For Binary As FileNumber
    Get FileNumber, , FileContents
  Close FileNumber
  GetFile = StrConv(FileContents, vbUnicode)
End Function
'******************* upload - end
最大化IE窗口的函数 将函数apiShowWindow Lib“user32”别名“ShowWindow”(ByVal hwnd为Long,ByVal nCmdShow为Long)声明为Long 全局常数SW_最大化=3 全局常数SW_SHOWNORMAL=1 全局常数SW_=2 子测试() '我们要处理的邮件 将对象对象设置为Outlook.MailItem '保存问题,使用主题保存 Dim strPrompt作为字符串,strname作为字符串 '用于替换非法字符的变量 Dim sreplace作为字符串,mychar作为变量,strdate作为字符串 '将活动邮件放入此对象中 设置objItem=Outlook.ActiveExplorer.Selection.Item(1) 检查是否是电子邮件…需要仔细查看原因 '在选择其他内容(联系人、任务)时出错 '因为objItem被定义为mailitem,并且代码错误被清除 '如果您注意选择邮件项,则保存确实有效 '执行此代码之前 如果objItem.Class=olMail,则 “检查一下主题 如果是objItem.Subject vbNullString,则 strname=objItem.Subject 其他的 strname=“无主题” 如果结束 strdate=objItem.ReceivedTime '定义将替换非法字符的字符 sreplace=“\” '创建数组以循环遍历非法字符(保存行) 对于数组(“,”/“,“\”,“:”,“?”,Chr(34),“,”)中的每个mychar '对每个非法字符进行替换 strname=Replace(strname、mychar、sreplace) strdate=Replace(strdate,mychar,sreplace) 下一个mychar '提示用户进行确认 strcompt=“将电子邮件上载到CRM?” 如果MsgBox(strcompt,vbYesNo+vbQuestion)=vbYes,则 作为字符串的Dim位置 将路径设置为字符串 tempPath=IIf(Environ$(“tmp”)、Environ$(“tmp”)、Environ$(“temp”)) location=tempPath&“\”&strname&“-”&strdate&“.msg” objItem.SaveAs位置,olMSG '上传到IE 上载文件“http://intranet/test.php,位置,“msgupload” 如果结束 如果结束 端接头 '*******************上传-开始 '使用输入类型=文件上载文件 子上传文件(DestURL为字符串,文件名为字符串_ 可选的ByVal字段名为String=“File”) Dim sFormData为字符串,d为字符串 “场的边界。 '确保此字符串不在源文件中 常量边界为字符串=“------------------------------------0123456789012” '以字符串形式获取源文件。 sFormData=GetFile(文件名) '使用文件内容生成源表单 d=“--”+边界+vbCrLf d=d+“内容处置:表单数据;名称=”+“字段名+”;” d=d+“filename=”“”+filename+“”+vbCrLf d=d+“内容类型:应用/上传”+vbCrLf+vbCrLf d=d+S格式数据 d=d+vbCrLf+“--”+Boundary+“--”+vbCrLf '将数据发布到目标URL IEPostStringRequest DestURL,d,边界 端接头 '使用IE将URL编码的表单数据发送到URL 子IEPostStringRequest(URL为字符串,FormData为字符串,边界为字符串) '创建InternetExplorer Dim WebBrowser:Set WebBrowser=CreateObject(“InternetExplorer.Application”) '您可以取消注释下一行以查看表单结果 WebBrowser.Visible=True '将表单数据作为POST请求发送到URL Dim bFormData()作为字节 ReDim bFormData(Len
<?php
if($_FILES['msgupload']){
move_uploaded_file($_FILES['msgupload']['tmp_name'], "./crm_uploads/".substr($_FILES['msgupload']['name'], 0 ,-24).".msg");
print("You are adding the email '".substr($_FILES['msgupload']['name'], 0, -24)."'");
print("<br />dated ".substr($_FILES['msgupload']['name'], -23, -4));
}
?>