诱使Outlook认为我提交的infopath表单不是XML

时间:2009-08-08 07:56:40

标签: xml email infopath

我继承了一个生成InfoPath表单的应用程序。我需要添加功能,以便在离线时通过电子邮件提交表单。这个想法是表格可以离线填写,然后通过电子邮件发送,然后由另一个检查提交收件箱的应用程序处理。

不幸的是,我必须在服务器上使用WEBDav代码来检查相当于Outlook Web Access的电子邮件收件箱。 OWA阻止xml文件或从文件中剥离xml。我已尝试以编程方式将附件的名称设置为另一个扩展,但这不起作用,Outlook必须读取所有文件,如果找到XML标记,则将其从文档中取出。

我尝试过的是更改表单中的第一行并提交。我将<?xml version="1.0"更改为<?xsl version="1.0"。有效!似乎只要Outlook找不到'xml'字符串,那么它就不会认为它是一个xml文档。

目前,我正在使用按钮和一些JS以编程方式提交表单。

有没有办法可以在提交之前修改原始数据?即,将开始XML标记更改为XSL。或者也许更改编码?或混淆文件或其他什么?

总之,我需要让outlook认为提交的表单不是XML。解决方案必须自包含在XSN中。

编辑:使用InfoPath 2003.不确定Exchange版本,但我认为它也是2003。

2 个答案:

答案 0 :(得分:0)

你可以将文件加密到outlook看不到的东西 - 换句话说是二进制文件?听起来有点像隐写术(隐藏的消息)但是如果你将数据编码成其他二进制对象 - 比如图像可能会怎么样?

答案 1 :(得分:0)

我以前用过这个并且工作得非常好。虽然现在几年前。它适用于Exchange 2003.但不确定它是否适用于Exchange 2008.

Public Function retrieve() As Boolean
    Dim allOK As Boolean = True
    Dim rec As ADODB.Record
    Dim rs As ADODB.Recordset
    Dim url As String
    Dim sql As String
    Dim iMessage As CDO.Message = New CDO.MessageClass
    Dim numAttachments As Integer
    Dim DeleteEmail As Boolean = False
    Dim EmailsFound As Integer = 0
    Try

        rec = New ADODB.Record
        rs = New ADODB.Recordset

        url = "Url to outlook web access inbox"

        rec.Open(url, , ConnectModeEnum.adModeReadWrite, , , AppSettings(MAILBOX_USERNAME), AppSettings(MAILBOX_PASSWORD))

        ' Build the SQL query for the messages.
        sql = "select "
        sql = sql & " ""urn:schemas:mailheader:subject"""
        sql = sql & ", ""urn:schemas:httpmail:hasattachment"""
        sql = sql & ", ""DAV:href"""
        sql = sql & ", ""urn:schemas:httpmail:from"""
        sql = sql & " from scope ('shallow traversal of "
        sql = sql & """" & url & """" & "') "

        If IsDebugEnabled Then log.Debug("retreieveEmails() - Opening Recordset:" & sql)


        ' Open the recordset.
        rs.Open(sql, rec.ActiveConnection, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockOptimistic)

        If Not rs.BOF And Not rs.EOF Then
            rs.MoveFirst()
            ' Loop through all of the messages in the recordset

            Do Until rs.EOF
                EmailsFound += 1
                DeleteEmail = False


                If Not rs.Fields("urn:schemas:mailheader:subject").Value Is System.DBNull.Value Then
                    iMessage.DataSource.Open(System.Convert.ToString(rs.Fields("DAV:href").Value), rec.ActiveConnection, ADODB.ConnectModeEnum.adModeRead, ADODB.RecordCreateOptionsEnum.adFailIfNotExists, ADODB.RecordOpenOptionsEnum.adOpenSource, "", "")
                    'Check that the Attachment is an XML file
                    For Each objAttachment As CDO.IBodyPart In iMessage.Attachments
                        If CStr(objAttachment.FileName & "").ToUpper.EndsWith(".XML") Then
                            'Save the Attachment off
                            objAttachment.SaveToFile(IO.Path.Combine(AppSettings(TEMP_IN_DIR), objAttachment.FileName))
                            DeleteEmail = True
                        End If
                    Next
                End If

                If DeleteEmail Then
                    delete(rs.Fields("DAV:href").Value)
                End If
                rs.MoveNext()
            Loop
        Else
            ' No Emails Found
        End If


        Return True
    Catch e As Exception
        'Log the error
        Return False
    Finally
        Try
            rs.Close()
        Catch
        End Try
        Try
            rs = Nothing
        Catch
        End Try
        Try
            rec.Close()
        Catch
        End Try
        Try
            rec = Nothing
        Catch
        End Try
    End Try

End Function