I have very busy recently so I have had no time to blog.
At work I have no way to get my private email as the corporate firewall blocks IMAP4 and POP3 connections which is a pain. I am using Desktop Sidebar in order to aggregate RSS feeds and so I thought why not create an RSS feed for my private email account. I was amazed how simple it was.
At work I am not so interested in the content of my private email more to see if I have received a mail. Which means that I am only interested in the subject and the sender. Naturally for other people that might not be the case but the code would be simple to extend to deal with that case.
First I downloaded Lumisoft's excellent and free SMTP, POP3 and IMAP4 libary and RSS.NET from source forge.
All I needed to do was create an ASP.NET project and write the following lines of code :
using
LumiSoft.Net.IMAP.Client;
using
Rss;
.....
LumiSoft.Net.IMAP.Client.IMAP_Client myClient = new IMAP_Client();
myClient.Connect("mailserver",143);
myClient.Authenticate("username","password");
myClient.SelectFolder("Inbox");
RssChannel channel = new RssChannel();
int noMessages = myClient.MessagesCount;
// this will return all messages normally I return the last 20
IMAP_FetchItem[] fetchItems = myClient.FetchMessages(noMessages,-1,false,true,false);
for(int i=fetchItems.Length-1;i>-1 ;i--)
{
IMAP_FetchItem fetchItem = fetchItems[i];
LumiSoft.Net.Mime.MimeParser p = new LumiSoft.Net.Mime.MimeParser(fetchItem.Data);
string str_to = ""; foreach(string t in p.To){str_to += t.Replace("<","").Replace(">","") + ";\n";}
RssItem item = new RssItem();
item.Title = p.Subject;
item.Description = p.From;
item.PubDate = p.MessageDate;
channel.Items.Add(item);
}
myClient.Disconnect();
channel.Title = "Private Email";
channel.Description = "Email";
channel.LastBuildDate = channel.Items.LatestPubDate();
channel.Link=new Uri("http://asp.net page returning feed");
RssFeed feed = new RssFeed();
feed.Channels.Add(channel);
Response.ContentType = "text/xml";
feed.Write(Response.OutputStream);
Response.End();
Now that I have an rss feed for my email I can use desktop sidebar to aggregate them. Of course it will probably make sense for me to create a secure rss feed. I assume using SSL will make the most sense and I see some aggregators support such feeds.
The great thing is that using Hand/RSS for Palm OS® v.1.08 I can now aggregate rss feeds on my Treo 600 phone.