Let's Talk About .NET, Java, and Various File Formats!

Archive for December, 2011

Download only new messages from Gmail in Thunderbird via POP3

Mozilla Thunderbird is a very good email client and it is free too. I like it a lot as it allows to setup multiple email accounts without worrying about “Profiles” unlike Microsoft Outlook. It is very light and easy to use. It also provides features to compact your local database or setup limit on the emails to keep in your local folder.

I had only one problem while setting Gmail. Whenever I configured my Gmail account with Thunderbird, it started downloading all the older emails which I had read already. As I had a lot of emails in my Gmail account, it would take a lot of time to download older emails.

Well, at last I figured this out! I had to make a few changes in my ‘Gmail Settings’.  You can also follow the below steps to download only new messages from your Gmail account when setting Thunderbird with POP3:

  • Open your Gmail account.
  • Go to Settings
  • Select ‘Forwarding and POP/IMAP’
  • Under ‘POP Download’ Select ‘Enable POP for mail that arrives from now on’
  • To retain original copy, Select ‘keep Gmail’s copy in the inbox’

Please also see the following snapshot to give you a better idea:

Download only new messages from Gmail in Thunderbird using POP3

I hope this helps you in resolving the issue of downloading only new messages from the Gmail account in Thunderbird via POP3.

Read File from Disk into MemoryStream using C# or VB.NET

Reading a file from the disk into the MemoryStream is a very common requirement while working with files in your .NET applications. It is important to read the files to MemoryStream when you want to process the file inside memory. For example, when you want to render a file from the server to the browser. This is very simple and you can use the following code snippet to read the file contents from the disk to the MemoryStream.

C# Code Snippet:

//open file from the disk (file path is the path to the file to be opened)
using (FileStream fileStream = File.OpenRead(filePath))
{
//create new MemoryStream object
MemoryStream memStream = new MemoryStream();
memStream.SetLength(fileStream.Length);
//read file to MemoryStream
fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
}

VB.NET Code Snippet:

‘open file from the disk (file path is the path to the file to be opened)
Using fileStream As FileStream = File.OpenRead(filePath)
‘create new MemoryStream object
Dim memStream As New MemoryStream()
memStream.SetLength(fileStream.Length)
‘read file to MemoryStream
fileStream.Read(memStream.GetBuffer(), 0, CInt(Fix(fileStream.Length)))
End Using

Why this delivery? Software Boys Song – Very Funny

These guys have made a parody of ‘Why this kolaveri di’. It’s very funny. Software guys are really gonna enjoy this. 🙂