0

i am using JACOB.jar to access outlook . i am getting the count of my inbox mails and each email session id also . can anyone help me to find how to read each mails from outlook with jacob.jar

package com.cicada.stratos.etc;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.*;
public class OutLook {
public static void main(String[] args)
{
ActiveXComponent ol = new ActiveXComponent("Outlook.Application");
Dispatch dsp = new Dispatch();
Dispatch olo = ol.getObject();
Dispatch myNamespace = Dispatch.call(olo, "GetNamespace","MAPI").toDispatch();
Dispatch myFolder = Dispatch.call((Dispatch) myNamespace,"GetDefaultFolder", new      Integer(6)).toDispatch();
Dispatch items = Dispatch.get(myFolder, "Items").toDispatch();
Dispatch mails = Dispatch.get(myFolder, "Items").toDispatch();

int count = Dispatch.call(items, "Count").toInt();
System.out.println("Totl Msg Count"+count);
for (int i = 1; i <= count; i++)
{
Dispatch item;
item = Dispatch.call(items, "Item", new Integer(i)).toDispatch();
String msg = item.toString();


System.out.println(msg);
//System.out.println(msgs);

}
}
}
Nidhin
  • 167
  • 1
  • 5
  • 26
  • Why do you not use JavaMail to read you mails – JHDev Oct 20 '14 at 10:28
  • i cant use the mail server because all my client using outlook and they gave the option delete after download to outlook that is the main issue i cant use the java mail – Nidhin Oct 20 '14 at 10:47
  • What do you want to do after reading the mails? How do you want to handle formatting? What about attachments? – piet.t Oct 20 '14 at 10:53
  • i just want to show mails. no need of attachments, only TO FROM sub and MESSAGE, then i will show that in jsp – Nidhin Oct 20 '14 at 10:55
  • So if I understand, you will parse the MSG Files. If so, you can use Apache POI see this link maybe help. http://poi.apache.org/hsmf/index.html – JHDev Oct 20 '14 at 11:12
  • thank you .. my requirement is to read mail from outlook inbox .. i can able to access outlook with the above code and count the inbox messages . if that possible can i read the message with jacob? – Nidhin Oct 20 '14 at 11:21
  • Maybe this link help you https://community.oracle.com/thread/1317511 – JHDev Oct 20 '14 at 11:51
  • in that link they are not telling any solutions. i am using Dispatch myFolder = Dispatch.call((Dispatch) myNamespace,"GetDefaultFolder", new Integer(6)).toDispatch(); this line to access the inbox .. in that link they are giving are giving only to access the inbox . – Nidhin Oct 20 '14 at 11:55

0 Answers0