Spire.Email for .NET is a professional .NET Email library specially designed for developers to create, read and manipulate emails from any .NET (C#, VB.NET, ASP.NET) platform with fast and high quality performance.

Fri Aug 20, 2021 1:35 pm

Hi. Yesterday's reply from Annika works great in VB.Net. I have tried to convert the same thing to C# Xamarin (I need the code in both VB.Net and C#). This is what I have:
Code: Select all
            StringBuilder sb = new StringBuilder();
            ImapMessageCollection msgs = imap.Search("'Subject' Contains '2021'");

            for(int i = 0; i < msgs.Count; i++)
            {
                Spire.Email.MailMessage originalMail = imap.GetMessageText(msgs(i));
                //Extract the body text
                String bodyText = originalMail.BodyText;
                sb.Append(bodyText);
            }


The problem is that there's an error which says 'Method name expected' for msgs(i). msgs is a variable, apparently. What is the correct format for this line 'Spire.Email.MailMessage originalMail = imap.GetMessageText(msgs(i));'?

Thank you.

Jonathan99
 
Posts: 6
Joined: Wed Aug 18, 2021 4:51 pm

Mon Aug 23, 2021 7:45 am

Hello,

Thank you for your inquiry.
Kindly note that the arg of "imap.GetMessageText()" is the sequence number of the message, so please modify the arg as below.
Code: Select all
MailMessage originalMail = imap.GetMessageText(msgs[i].SequenceNumber);

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Aug 23, 2021 9:26 am

Thanks again - it now works great.

Jonathan99
 
Posts: 6
Joined: Wed Aug 18, 2021 4:51 pm

Mon Aug 23, 2021 12:35 pm

Hi,

You're welcome.
If you have other questions about using Spire.Email in the future, please feel free to contact us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Email