ivan
  • ivan
  • 100% (Exalted)
  • Administration Topic Starter
14 years ago
JavaScript Example

The following code demonstrates how to receive email from a POP3 mail account. This sample downloads emails from POP3 server and deletes the email after the email is retrieved.


MailServerPop3 = 0;
MailServerImap4 = 1;

try
{
    var oServer = new ActiveXObject("EAGetMailObj.MailServer");
    // please change the server, user, password to yours
    oServer.Server = "pop3.adminsystem.com"
    oServer.Protocol = MailServerPop3;

    oServer.User = "testx";
    oServer.Password = "testpassword";

    // If your server requires SSL connection, 
    // Please add the following codes.
    oServer.SSLConnection = true;
    oServer.Port = 995;

    var oClient = new ActiveXObject("EAGetMailObj.MailClient");
    oClient.LicenseCode = "TryIt";
    
    // Connect POP3 server.
    oClient.Connect(oServer);

    var infos = new VBArray(oClient.GetMailInfos()).toArray();
    for (var i = 0; i < infos.length; i++) {
        var info = infos[i];

        // Receive email from POP3 server
        var oMail = oClient.GetMail(info);
        

        // Save email to local disk
        oMail.SaveAs("d:\\" + i + "_test.eml", true);

        // Mark email as deleted on server.
        oClient.Delete(info);
    }

    // Quit and pure emails marked as deleted from POP3 server.
    oClient.Quit
}
catch( err )
{
 
      WScript.Echo( err.description );
 
}

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.