Using IMAP To Access Calendar on Exchange Server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nh_capricorn

    Using IMAP To Access Calendar on Exchange Server

    Hi,

    I am fairly new to .NET (coming from a Java background) and I am trying to
    port an application that I originally wrote in Java, to .NET / C#. My problem
    is that I cannot find a C# analog for the javax.mail library. My original
    program used this to access the calendar on Exchange, via IMAP and retrieve
    appointments.

    I have no idea how to do this. Any help, advice, or even general guidelines
    would be much appreciated. I would be very surprised if what I wanted to do
    wasn't possible.

    Here's a snippet of the original Java code. As you can see, it should be
    fairly easy to do:

    public void checkCal() {

    Folder folder = null;
    Store store = null;


    // 1. Open the mailbox and retrieve messages
    System.out.prin tln("user: " + user + "Password: " + passwd);
    URLName url = new URLName(protoco l, imapHost, -1, mbox, user, passwd);
    Session session = Session.getDefa ultInstance(pro ps, null);
    session.setDebu g(false);
    store = session.getStor e(url);
    store.connect() ; //this is a resource that needs to be cleaned up!
    folder = store.getDefaul tFolder();
    folder = folder.getFolde r(mbox);
    folder.open(Fol der.READ_WRITE) ;
    int totalMessages = folder.getMessa geCount();

    System.out.prin tln("Num Messages=" + totalMessages);
    Message[] msgs = folder.getMessa ges();
    FetchProfile fp = new FetchProfile();
    fp.add(FetchPro file.Item.ENVEL OPE);
    folder.fetch(ms gs, fp);
    }


  • nh_capricorn

    #2
    RE: Using IMAP To Access Calendar on Exchange Server

    Oops.... what I meant to say was that I couldn't find a .NET analog for
    javax.mail.... I am writing the program in C#

    "nh_caprico rn" wrote:
    [color=blue]
    > Hi,
    >
    > I am fairly new to .NET (coming from a Java background) and I am trying to
    > port an application that I originally wrote in Java, to .NET / C#. My problem
    > is that I cannot find a C# analog for the javax.mail library. My original
    > program used this to access the calendar on Exchange, via IMAP and retrieve
    > appointments.
    >
    > I have no idea how to do this. Any help, advice, or even general guidelines
    > would be much appreciated. I would be very surprised if what I wanted to do
    > wasn't possible.
    >
    > Here's a snippet of the original Java code. As you can see, it should be
    > fairly easy to do:
    >
    > public void checkCal() {
    >
    > Folder folder = null;
    > Store store = null;
    >
    >
    > // 1. Open the mailbox and retrieve messages
    > System.out.prin tln("user: " + user + "Password: " + passwd);
    > URLName url = new URLName(protoco l, imapHost, -1, mbox, user, passwd);
    > Session session = Session.getDefa ultInstance(pro ps, null);
    > session.setDebu g(false);
    > store = session.getStor e(url);
    > store.connect() ; //this is a resource that needs to be cleaned up!
    > folder = store.getDefaul tFolder();
    > folder = folder.getFolde r(mbox);
    > folder.open(Fol der.READ_WRITE) ;
    > int totalMessages = folder.getMessa geCount();
    >
    > System.out.prin tln("Num Messages=" + totalMessages);
    > Message[] msgs = folder.getMessa ges();
    > FetchProfile fp = new FetchProfile();
    > fp.add(FetchPro file.Item.ENVEL OPE);
    > folder.fetch(ms gs, fp);
    > }
    >
    >[/color]

    Comment

    • Gerry Hickman

      #3
      Re: Using IMAP To Access Calendar on Exchange Server

      nh_capricorn wrote:
      [color=blue]
      > port an application that I originally wrote in Java, to .NET / C#. My problem
      > is that I cannot find a C# analog for the javax.mail library.[/color]

      Wow, the Java code looks quite elegant! I'd be interested to see side by
      side compare with .NET

      Exchange traditionally used MAPI, and if you do a search on "CDO" you'll
      find a lot of information about the object model and what you can do
      with it - including managing calendars, but I'm not sure about IMAP.
      You're talking "open-standards" here, which don't always sit too well in
      the Microsoft world!

      One thing I did notice that's funny - the latest Exchange SDK states
      that it's "not compatible with .NET" and guess what... you have to use
      COM interop! I guess .NET doesn't "rock" quite as hard as we were lead
      to believe in the latest press release.

      --
      Gerry Hickman (London UK)

      Comment

      Working...