none
How to receive the XML files along with Doc files from Email using POP3 adapter

    Question

  • hI

    i have a solution which will receive documents from Email using POP3 adapter.

    I am using custome pipeline componet. I am able to receive the ZIP files and the doc,PDF, excel files as an attachments.

    However when i send the XML file as an attachment, i am facing the error. Can you help me to receive the XML file using POP3 adapter.

    Error:

    Multi-part message 'Rcv_ElectronicDocuments' has body part 'New.xml', expected body part '{1AC22A03-B23F-4E32-9CB4-840F93EE0571}'.
           
    Exception type: WrongBodyPartException
    Source: Microsoft.XLANGs.BizTalk.Engine

    Thanks

    mahesh

    Monday, May 28, 2012 7:37 AM

All replies

  • Hi,

    Create the multipart for the attachment as XMLDocument and then try assigning it to the actual XML Schema type. This should work .


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.

    Monday, May 28, 2012 8:03 AM
  • i have created the normal message with the type of System.Xml.XmlDocument.

    This will wbl to receive non xml file. however it is not able to receive the other than XML files like doc,pdf,excel.

    do i need to create Multi part message?

    Regards

    Mahesh

    Monday, May 28, 2012 10:00 AM
  • Hi,

    Did not understand your comments. Are you able to receive the XML file. Every message flowing through biztalk is XML, so not clear what the issue is now.


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.

    Monday, May 28, 2012 10:08 AM
  • sorry,

    I am able to receve the Doc, excel and pdf using normal message, with document type as System.Xml.XmlDocument.

    i am not able to receive the XML files.

    Regards

    Mahesh

    Monday, May 28, 2012 10:16 AM
  • Hi,

    If your message type is XMLDocument you should be able to receive the XML. Use a multipart of type XMLDocument. You can see the sample code here.


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.


    • Edited by DPS Bali Monday, May 28, 2012 10:22 AM
    Monday, May 28, 2012 10:21 AM
  • i have created the message with message type as System.Xml.XmlDocument.

    also i am using "oXMessage               = Rcv_ElectronicDocuments; " this where oXMessage message type as  Microsoft.XLANGs.BaseTypes.XLANGMessage.

    do i need to change the message(Rcv_ElectronicDocuments )  type also to Microsoft.XLANGs.BaseTypes.XLANGMessage.

    i am using message Rcv_ElectronicDocuments in the orchestration receive sape. and i am using  System.Xml.XmlDocument as a messagetype in the receive port in orchestartion port.

    this is how i have created the solution. even though i am not able to receive xml files .

    facing Multi-part message 'Rcv_ElectronicDocuments' has body part 'New.xml', expected body part '{1AC22A03-B23F-4E32-9CB4-840F93EE0571}'. error

    Regards

    Mahesh

    oXMessage               = Rcv_ElectronicDocuments;
    Monday, May 28, 2012 10:47 AM
  • Also ,

    to add more..i am not using the MIME decoder , i am using custome pine line code. But this  is not giving any error. I am facing error while receive shape of orchestration.

    Dim bEmailStatus As Boolean = False
                    Dim bNoAttachmentsOption2 As Boolean = False
                    Dim iEmailOption1 As Integer = 0

                    Dim IMsgCtx As IBaseMessageContext = pInMsg.Context
                    Dim strReceiveLocationName As String = IMsgCtx.Read("ReceiveLocationName", "http://schemas.microsoft.com/BizTalk/2003/system-properties").ToString()
                    pInMsg.Context.Promote("ReceiveLocationName", "http://SIS.EDM.ToCaptiva.Schemas.ReceiveLocationName_PropertySchema", strReceiveLocationName)

                    Dim strInboundTransportType As String = IMsgCtx.Read("InboundTransportType", "http://schemas.microsoft.com/BizTalk/2003/system-properties").ToString()

                    Dim strMessageID As String = pInMsg.MessageID.ToString()
                    pInMsg.Context.Promote("MessageID", "http://SIS.EDM.ToCaptiva.Schemas.ReceiveLocationName_PropertySchema", strMessageID)

                    'msgRecDateTime = Datetime when message enters into BizTalk
                    Dim msgRecDateTime As DateTime
                    'fileSize : Size of file received from client
                    Dim fileSize As ULong = 0
                    'recFileName = Name of file received from client
                    Dim recFileName As String
                    Dim strError As String = ""
                    Dim strFileName As String = "NO ERROR"

                    'Get Msg Receive time
                    msgRecDateTime = System.DateTime.Now()

                    'FILE/eFAX/FTP
                    If strInboundTransportType = "FILE" Or strInboundTransportType = "FTP" Then
                        ' System.Diagnostics.EventLog.WriteEntry("After", "")

                        If Not strReceiveLocationName.ToUpper.Contains("EFAX") Then
                            Dim fname As String()
                            pInMsg.GetSize(fileSize, True)
                            recFileName = IMsgCtx.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString()
                            fname = recFileName.Split("\")
                            'pInMsg.Context.Promote("ReceiveLocationName", "http://SIS.EDM.ToCaptiva.Schemas.ReceiveLocationName_PropertySchema", bEmailStatus)
                            pInMsg.Context.Promote("FileName", "http://SIS.EDM.ToCaptiva.Schemas.ReceiveLocationName_PropertySchema", fname(fname.Length - 1))
                            pInMsg.Context.Promote("FileSize", "http://SIS.EDM.ToCaptiva.Schemas.ReceiveLocationName_PropertySchema", (fileSize / 1024).ToString())
                            pInMsg.Context.Promote("FilePath", "http://SIS.EDM.ToCaptiva.Schemas.ReceiveLocationName_PropertySchema", recFileName.ToString())
                        End If

                        'POP3
                    ElseIf strInboundTransportType = "POP3" Then
                        Dim nParts As Integer
                        Dim partName As String
                        Dim msgPart As IBaseMessagePart
                        Dim msgSize As Long = 0

                        nParts = pInMsg.PartCount

                        For i As Integer = 0 To nParts - 1
                            msgPart = pInMsg.GetPartByIndex(i, partName)

                            strFileName = CType(msgPart.PartProperties.Read("FileName", "http://schemas.microsoft.com/BizTalk/2003/mime-properties"), String)
                            msgSize += msgPart.Data.Length


                            If i > 0 Then
                                If strFileName = "" Then
                                    strError = "MIME ERROR"
                                End If
                            End If

                            If nParts = 2 Then

                                'Update the information for Email Option 1 and Option 2
                                If i = 1 Then
                                    If (msgPart.ContentType <> "text/plain") AndAlso (msgPart.ContentType <> "text/html") Then
                                        'If iEmailOption1 = 0 then,
                                        'Assign ReceiveMessage of 0 in the orchestration
                                        iEmailOption1 = 0
                                    Else
                                        'If iEmailOption1 = 1 then,
                                        'Assign ReceiveMessage of 1 in the orchestration
                                        iEmailOption1 = 1
                                        'If there is no attachemnts Email Scenario 2
                                        bNoAttachmentsOption2 = True
                                    End If
                                End If

                                'SIS.EDM.ToCaptiva.Components.Helper.Helper.PDFConvertion(msgPart.Data, strReceiveLocationName, strMessageID);
                            End If
                        Next

                        'System.Diagnostics.EventLog.WriteEntry("EmailOption", iEmailOption1.ToString())

                        'Check number of attachments
                        If nParts > 64 Then
                            'System.Diagnostics.EventLog.WriteEntry("Exceeded the attachment - POP3", "Total Number of attachments are " + nParts.ToString())
                            'SIS.EDM.ToCaptiva.Components.Helper.Helper.SendMail("", "", "Exceeded Attachments : " + msgSize);
                            bEmailStatus = True
                        End If

                        'Check the size of the mail including the attachments
                        If msgSize > 12582912 Then
                            'System.Diagnostics.EventLog.WriteEntry("Exceeded the attachment size - POP3", "File size is " + msgSize.ToString())
                            'SIS.EDM.ToCaptiva.Components.Helper.Helper.SendMail("", "", "Exceeded Mail size : " + msgSize);
                            bEmailStatus = True

                        End If
                    End If
    Catch xPathEx As XPathException

                    Throw New ApplicationException("Exception : ", xPathEx)
                Catch ex As Exception

                    Throw New ApplicationException("Error trying to write encoded document : ", ex)
                End Try

    Monday, May 28, 2012 10:55 AM
  • hI

    i have a solution which will receive documents from Email using POP3 adapter.

    i have created one  message with message type as System.Xml.XmlDocument, and oXMessage as a variable and type as Microsoft.XLANGs.BaseTypes.XLANGMessage.

    also i am assigning the value in orchestration like  "oXMessage               = Rcv_ElectronicDocuments;

    i am using message (Rcv_ElectronicDocuments) in the orchestration receive sape. and i am using  System.Xml.XmlDocument as a messagetype in the receive port in orchestartion port.

    this is how i have created the solution. even though i am not able to receive xml files .

    facing Multi-part message 'Rcv_ElectronicDocuments' has body part 'New.xml', expected body part '{1AC22A03-B23F-4E32-9CB4-840F93EE0571}'. error

    Regards

    Mahesh

    Monday, May 28, 2012 2:09 PM