none
Downloading Outlook Forms email using EWS RRS feed

  • Question

  • Hi,

    I am trying to download the Outlook Forms emails as it is using EWS however the same is not happening. The Outlook Clas Property that I managed to identify by writing some logs is as below.

    05/09/2014 06:05:01.875 - Login SuccessFull in Mail Box:shEBSFinanceEs ----------------- Mail Count is : 2
    05/09/2014 06:05:02.406 - Mails Item Class Property Is :IPM.Note.Unclaimed Property Request
    05/09/2014 06:05:02.593 - Login SuccessFull in Mail Box:shEBSFinanceEs ----------------- Mail Count is : 2
    05/09/2014 06:05:02.624 - Mails Item Class Property Is :IPM.Note.Unclaimed Property Request

    I am also adding the patch of code that is being used to download the email in .eml format

       Try

                                If Not Mesage.BodyHtmlText Is Nothing Then

                                    bodyText = Mesage.BodyHtmlText

                                ElseIf Not Mesage.BodyPlainText Is Nothing Then

                                    bodyText = Mesage.BodyPlainText

                                End If

                            Catch ex As Exception

                            End Try

                            MailDate = Mesage.ReceivedTime

                            'Priority = msg.Importance.ToString

                            If Mesage.Importance = Importance.High Then

                                Priority = "high"

                            ElseIf Mesage.Importance = Importance.Normal Then

                                Priority = "medium"

                            Else

                                Priority = "low"

                            End If

                            References = Mesage.References

                            i = 0

                            Try

                                TempFolderPath = FolderPath

                                If CheckForDirectory(TempFolderPath) Then

                                    TempFolderPath += "\" + Temp

                                    If CheckForDirectory(TempFolderPath) Then

                                        TempFolderPath += "\" + System.Guid.NewGuid().ToString() 'DateTime.Now.ToString("yyyyMMddHHmmssmm")

                                    End If

                                End If

                                FilePath = TempFolderPath + "\"

                                RawFilePath = TempFolderPath + "\RawEmail"

                                If CheckForDirectory(TempFolderPath) Then

                                    If CheckForDirectory(RawFilePath) Then

                                        RawFilePath += "\"

                                        RawFileName = System.Guid.NewGuid().ToString() + ".eml" 'DateTime.Now.ToString("yyyyMMddHHmmssmm") + ".eml"

                                        strfileName = RawFilePath + RawFileName

                                    End If

                                End If

                                Dim Email As String = String.Empty

                                Dim file As FileStream = New FileStream(strfileName, FileMode.CreateNew)

                                Dim mimeContent As String = Mesage.MimeContent.Text

                                Dim buffer As Byte() = System.Text.Encoding.UTF8.GetBytes(mimeContent)

                                Using file

                                    file.Write(buffer, 0, buffer.Length)

                                End Using

                                file.Close()

    I am not receiving any error with this code however the Outlook Forms is not getting downloaded in .eml or .msg format using EWS. Also how can I get Outlook forms as HTML in email body text properties.

    Appreciate the help!

    Regards,

    Roshan Rajan

    Thursday, June 19, 2014 2:04 PM

All replies

  • What your trying to do won't work with EWS, If you use the MimeContent like your trying this won't contain any of the Extended properties associated with the Form and all you will get is the RFC822 content of the message eg headers, body ,subject, attachments etc.

    The MSG (or compound message format) is an Office file format so to use this you will need to use an Office API like the Outlook Object Model or you could use a third party library like Redemption http://www.dimastr.com/redemption/home.htm which uses Extended MAPI to be able to create these.

    With EWS you can extract the data from the Item yourself using the individual extended properties associated with the form (use an MAPI editor like OutlookSpy or MFCMapi to work these out) and create your own export format eg export to XML or a HTML representation. Depends what your trying to achieve by downloading the message ?

    Cheers
    Glen

    Friday, June 20, 2014 3:38 AM