Search code examples
emailvbscripttcshstartupscript

Deleting email automatically


The Problem:

I'm looking for a way to create a program that visits an email host site and log in with a specific credentials and deletes all message at the Inbox and clears the Trash folder.

Background:

I have an email with my domain and that email is hosted on some ISP server. However I have enabled auto-forward all my emails to my gmail, the thing is that there is no option for auto deleting arriving messages so my inbox with its limited size (10MB) gets full and I stop receiving emails. My solution till today was to empty it manually when I remember to or when someone calls me and asks me why my inbox is full. The ISP said that in order to overcome this problem I should upgrade my qouta at their server for some extra $$ per month and Its a thing that I won't do.

So I'm looking for a way to do this automatically. My impressions as beginner program is to write a script that does that and runs at every system start. My system would be Windows 7, so I thought to work it out with VBScript.

It would be my first experience with VBScript, so any suggestions would be welcomed. On the other hand if you think there is a better way to do that rather than VBScript tell me :) I prefer to write a program that I fully understand, so my experience in programming would be: Pascal/C/C++/Java/C#/ML/Prolog/Squeak(smalltalk)/TCSH(CShell).

Thanks in advance, Jalil


Solution

  • Depends on what email server you use but if you have POP3 access all you really need to do is to connect to it with a TCP\IP connection and send some simple commands. So any language where you have a good library for making a simple connection should be fine.

    Below I show how you could do it just using telnet (be careful doing this over the internet though since it's not using a secure connection):

    telnet [hostname] 110
    
    USER [username]
    PASS [password]
    LIST - gets you a list of all emails showing the msgindex and it's size    
    DELE [msgindex]    
    QUIT - the emails aren't deleted until you send QUIT!
    

    All you need to do is to create a connection and send those commands in that order (waiting for the response and checking if it was + or - to know if it went ok or not).

    Regarding language, if you do want to use a script language I'd consider Powershell since I think that supports the .Net framework classes and so would be really easy to do.