+1 vote

Hi,
I have purchased a license 2nd july from limilabs, so expecting technical support for this.

Problem:
I'm using imap.GetMessageInfoByUID(uids) method to download headers part of mails from gmail and this is quite faster. But it does not have body of the mail. I need to fetch body but that needs an extra method BodyStructure structure = imap.GetBodyStructureByUID(uid) which is very slow as i'm looping it. Think about I have more than 4 lac of emails in my gmail account and it is taking too much time. Is there any solution can you provide so that fetching body will take less time.

Even I don't need whole body. I need only first 200 characters from the body. There seems no method like this in limilabs. Can you provide a method something like this so that we can fetch only 200 char and the speed will be too fast as compare to GetBodyStructureByUID method.

Waiting for your reply.

Thanks,
Sarathi

by (1.4k points)

1 Answer

0 votes
 
Best answer

1.
GetMessageInfoByUID downloads BodyStructure (MessageInfo.BodyStructure property) so you don't need to invoke GetBodyStructureByUID separately.

2.
When using GetMessageInfoByUID use overload that takes list of uids as a parameter (Imap.GetMessageInfoByUID(List uids)) as a parameter. It's certainly faster than looping over a uid list.

3.

Even I don't need whole body. I need only first 200 characters from the body.

This doesn't make much of difference in terms of speed.

4.
Use GetTextByUID to download text data:

string text = imap.GetTextByUID(info.BodyStructure.Text);

There is also a GetTextByUID bulk overload, that takes list of structures as a parameter: Imap.GetTextByUID(List structures). It fills every structure's Text and Data properties.

by (297k points)
selected by
I don't think so. I tried with different Gmail account.

It may be issue with internet speed.

Anyway thank you very much for your time and input.
I also noticed that getting new messages from Gmail is faster than retrieving old ones (~20% difference).
I just tried switching over to the bulk method and I get random errors like this.

 imap.GetTextByUID(struc);

"Tried to read 30340 bytes, only 16348 received. Please make sure that antivirus and firewall software are disabled or configured correctly."

When I do it non bulk and just loop it, it always works, just takes a long time.

Say I have 16000 structures and I'm sure that it's failing on one of the 16000 in the bulk - Then I have to try to do all 16000 again. Is there a way - to suppress the error and have mail.dll just try to re-download the one it failed on, so I don't have to attempt all 16000 again in bulk.
Unfortunately you can't suppress this error. This is a serious communication error, and usually means that either connection was cut or the server is acting incorrectly (it send less data than it previously declared). After this error is raised you need to reconnect.

You may try increasing timeout values: Imap.ReceiveTimeout and Imap.SendTimeout.

I'd also suggest using smaller bulks, this way you'll be retrying with much less data lost.
Increasing the Timeouts worked, I no longer get the errors. Thanks.  I do agree with the other poster, even using the bulk method it does take a very long time. 16,000 emails does take about 20 minutes.
...