MessageID is not geting displayed if Response.Write is used in EWS to access email (C# .NET)

Hi

I retrive email from Exchange and having propblem with some email does have the MessageID and some does not

I use this code

Dim client As IEWSClient = EWSClient.GetEWSClient(vEWSServer, vUserName, vUserPassword, vDomain)
Dim InboxUri as String = client.GetMailboxInfo().InboxUri
Dim Messages as ExchangeMessageInfoCollection
Messages = client.ListMessages(InboxUri)
For Each msgInfo as ExchangeMessageInfo In Messages
Response.write(Messahe ID: " & msgInfo.MessageId)
Next

But only some message has the Message ID and some does not have the Message ID

@CFITSupport,

I have observed the issue shared by you and request you to please share the test account to verify the issue on our end. Ideally, the MessageID must come for every message retrieved.

Hi

How do i privately send you the detail

@CFITSupport,

Please check screenshot that i have shared with you. This will help you to send private messages.screenshot.png (49.4 KB)

Hi Adnan,

I think i have privately sent you the details

Can you please check?

@CFITSupport,

I have worked with sample code shared by you using Aspose.Email 19.3 and unable to observe issue. I see that all emails have MessageId on my side.Can you please share which Aspose.Email version you are using on your end.MessageID.zip (664 Bytes)

Hi Adnan

I am sure that we use version 19.3

Can you please share your code without the login detail

Below is my full code

<%@ Import namespace=“Aspose.Email.Clients.Exchange” %>
<%@ Import namespace=“Aspose.Email.Clients.Exchange.WebService” %>

<%

    Application("EwsServer")      = 
    Application("EmailUserName")  = 
    Application("EmailPassword")  = 

Dim vContents as String

Dim vUserName as String = Application(“EmailUserName”)
Dim vUserPassword as String = Application(“EmailPassword”)
Dim vEWSServer as String = Application(“EwsServer”)
Dim vDomain as String = “coverforce”

Dim client As IEWSClient = EWSClient.GetEWSClient(vEWSServer, vUserName, vUserPassword, vDomain)
Dim InboxUri as String = client.GetMailboxInfo().InboxUri
Dim Messages as ExchangeMessageInfoCollection
Messages = client.ListMessages(InboxUri)

For Each msgInfo as ExchangeMessageInfo In Messages
Response.write("Message ID: " & msgInfo.MessageId.ToString() & “
”)
Next

%>

But the out put is like this

Message ID:
Message ID:
Message ID:
Message ID:
Message ID:
Message ID:
Message ID: 2aef403e9b174a329ba925a44ec7866f-JVKUGUBNKBZG6ZBNINMTE7CTNN4XAZKDOBRXYVLTMVZEI2LTMFRGYZLEPRJW25DQ@microsoft.com
Message ID:
Message ID: 40705@ucover.com.au
Message ID:
Message ID:
Message ID:

Hi Adnan,

I suspect that problem is from how we do the import statement which might lead to different class

Hi Adnan,

I discover that if i run it on Visual Studio as a console applcation then it can rerieve Message ID ok

But if I run it as a webpage in IIS then only some emails return Message ID

@CFITSupport,

I have attached the sample application and output obtained for your reference. If it were an API issue then issue must be reproduced in console based application. I request you to please verify the things and configurations on your end.

SampleEmail.zip (46.4 KB)

Exchange Out.zip (663 Bytes)

Hi Mudassir,

I have verify that It work in Console Application

However in IIS it only display Message ID of some email not all

Is there some way that you can test it in IIS the code that i supply?

@CFITSupport,

You may please share a working Visual Studio project with us reproducing the issue but it is not an API issue as if it were an API issue the console application would have reproduced the same issue.

Hi

Some time the problem won’t appear until in the environment

In this case, it is iis

I have already sent you you the full code for an aspx page this morning

@CFITSupport,

I have verified the same in Web based application as well using IIS express. It fetched the the MessageID correctly too. For your kind reference, I have attached the snapshot of sample and sample project too.

TestEmail.zip (3.3 MB)

Hi Musdasir

Can i ask what version of iis express you are using (Which Windows version)

And you are using what dot net frame work? 2 or 4

And which aspose dll you are using ( net Frame work 2 or 4 or profile)

@CFITSupport,

I request you to please provide us a sample solution application that is reproducing issue on your end. We will try that on our end to see if we can reproduce issue using your application or not. So far in both applications (Console and Web based) that we have shared with you as well, we have not been able to reproduce the issue.

Hi Mudassir,

Your suplied example for the aspx page try to do the
Console.WriteLine(msgInfo.Date);
Console.WriteLine(msgInfo.MessageId);

In a normal webpage I can’t display to the console

I replace the above 2 lines to the below

        HttpContext.Current.Response.Write("Date: " + msgInfo.Date + "<br>");
         HttpContext.Current.Response.Write("ID:" + msgInfo.MessageId + "<br>");

Then not all email display the Message ID

@CFITSupport,

I have observed the information shared by you and have been able to observe the issue on my end. An issue with ID EMAILNET-39456 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi Mudasir,

I find out what the problem is now

The line
HttpContext.Current.Response.Write(“ID:” + msgInfo.MessageId + “
”);

Should be HtmlEncode like below then it work

HttpContext.Current.Response.Write(“ID:” + Server.HtmlEncode(msgInfo.MessageId) + “
”);

@CFITSupport,

Its good to know that you have found solution. Please share feedback with us if there is still an issue.