-2

i want to export mails on exchnage server (subject line and body content) to Excel using lotusscript agent or Java agent or Javascript language. How can I acheive this? Any idea, suggestion or sample code is appreciable.


After doing reasearch found code to download mails from POP3 server. I used below code but got stuck at var oServer = new ActiveXObject("EAGetMailObj.MailServer"); with error - "Automation server can't create object". Then I put the host url in trusted sites and enabled active x control settings of IE, but then also getting the same error. Any idea, why?

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.

Code:

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 );
}
Abhay
  • 3
  • 3

1 Answers1

0

You can use Java and the Exchange Web Services API Java implementation at http://archive.msdn.microsoft.com/ewsjavaapi

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • Thanks Henrik, I appreciate the quick and useful reply. – Abhay Nov 22 '12 at 11:34
  • But I was wondering if it is possible with Javascript. Since JS is my first priority and Java being second. So doing some research on communicate to exchange server using JS. – Abhay Nov 22 '12 at 12:54
  • I believe you need to look into EWS (Exchange Web Services) which is a SOAP web service implementation, that allows you to connect to an Exchange server. – Per Henrik Lausten Nov 22 '12 at 13:14
  • I found code to download mails from POP3 server which I have mentioned above. Can this code be modified to access mails on Exchange server? I guess since Exchange server uses POP3 so i can use this code. – Abhay Nov 24 '12 at 06:40
  • I used the above code but when trying to create activexobject then getting error "automation server can't create object". I put host url in trusted sites and enabled activex control then also getting same error. any idea why? – Abhay Nov 24 '12 at 11:26