Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Downloading Outlook Forms email using EWS

$
0
0
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

                           IfNot Mesage.BodyHtmlTextIsNothing Then

                                bodyText = Mesage.BodyHtmlText

                           ElseIfNot Mesage.BodyPlainTextIsNothing Then

                                bodyText = Mesage.BodyPlainText

                           EndIf

                        Catch exAsException

                       EndTry

                        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"

                        EndIf

                        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")

                               EndIf

                           EndIf

                            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

                               EndIf

                           EndIf

                           Dim Email As String = String.Empty

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

                           Dim mimeContent AsString = Mesage.MimeContent.Text

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

                           Using file

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

                           EndUsing

                            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


Viewing all articles
Browse latest Browse all 7132

Trending Articles