none
How to get email body stored in widows mobile using MAPI.

    Question

  • I m trying to retrieve email detail from my windows mobile, everything work file but when I am trying to retrieve email body, it throws exception

    "Invalid type request".

    My code is as follows:

     

    Private Sub ReteriveSMS(ByVal folder As IMAPIFolderID)

            Dim CFolder As IMAPIFolder = folder.OpenFolder()

            CFolder.SortMessagesByDeliveryTime(TableSortOrder.TABLE_SORT_DESCEND)

            Dim messages As IMAPIMessage() = CFolder.GetNextMessages(CFolder.NumSubItems)

            For i As Integer = 0 To messages.Length - 1

                Dim msg As IMAPIMessage = messages(i)
                msg.PopulateProperties(EMessageProperties.DeliveryTime Or EMessageProperties.Sender Or EMessageProperties.Subject)

                Dim sen As IMAPIContact = msg.Sender

                Dim oSMS As XmlElement = oXMLDOM.CreateElement("SMS")
                oSMSHead.AppendChild(oSMS)

                Dim oSender As XmlAttribute = oXMLDOM.CreateAttribute("Sender")
                If Not sen Is Nothing Then
                    If String.IsNullOrEmpty(sen.FullAddress) Then
                        oSender.InnerText = "(No Address)"
                    Else
                        oSender.InnerText = sen.FullAddress
                    End If
                    '-------------------------------------------
                    'Added on 15 Nov 2010
                Else
                    oSender.InnerText = "(No Sender)"
                    '-------------------------------------------
                End If
                oSMS.SetAttributeNode(oSender)

                Dim oSubject As XmlAttribute = oXMLDOM.CreateAttribute("Subject")
                If String.IsNullOrEmpty(msg.Subject) Then
                    oSubject.InnerText = "(No Subject)"
                Else
                    oSubject.InnerText = msg.Subject
                End If
                oSMS.SetAttributeNode(oSubject)

                Dim oBody As XmlAttribute = oXMLDOM.CreateAttribute("Body")
                If String.IsNullOrEmpty(msg.Body.ToString()) Then
                    oBody.InnerText = "(No Body)"
                Else
                    oBody.InnerText = msg.Body.ToString()
                End If
                oSMS.SetAttributeNode(oBody)

                Dim oLDelivery As XmlAttribute = oXMLDOM.CreateAttribute("LocalDelivery")
                If String.IsNullOrEmpty(msg.LocalDeliveryTime) Then
                    oLDelivery.InnerText = "(No Delivery DateTime)"
                Else
                    oLDelivery.InnerText = msg.LocalDeliveryTime.ToString("dd/MMM/yyyy hh:mm tt")
                End If
                oSMS.SetAttributeNode(oLDelivery)

            Next

        End Sub

    Monday, November 15, 2010 7:11 AM