467,864 Members | 1,913 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,864 developers. It's quick & easy.

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.println("user: " + user + "Password: " + passwd);
URLName url = new URLName(protocol, imapHost, -1, mbox, user, passwd);
Session session = Session.getDefaultInstance(props, null);
session.setDebug(false);
store = session.getStore(url);
store.connect(); //this is a resource that needs to be cleaned up!
folder = store.getDefaultFolder();
folder = folder.getFolder(mbox);
folder.open(Folder.READ_WRITE);
int totalMessages = folder.getMessageCount();

System.out.println("Num Messages=" + totalMessages);
Message[] msgs = folder.getMessages();
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
folder.fetch(msgs, fp);
}
Jul 21 '05 #1
  • viewed: 7865
Share:
2 Replies
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_capricorn" wrote:
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.println("user: " + user + "Password: " + passwd);
URLName url = new URLName(protocol, imapHost, -1, mbox, user, passwd);
Session session = Session.getDefaultInstance(props, null);
session.setDebug(false);
store = session.getStore(url);
store.connect(); //this is a resource that needs to be cleaned up!
folder = store.getDefaultFolder();
folder = folder.getFolder(mbox);
folder.open(Folder.READ_WRITE);
int totalMessages = folder.getMessageCount();

System.out.println("Num Messages=" + totalMessages);
Message[] msgs = folder.getMessages();
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
folder.fetch(msgs, fp);
}

Jul 21 '05 #2
nh_capricorn wrote:
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.


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)
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Chuck Anderson | last post: by
5 posts views Thread by Mike | last post: by
1 post views Thread by Kjell Wilhelmsen | last post: by
5 posts views Thread by kapila Wijethilaka | last post: by
3 posts views Thread by Curt_C [MVP] | last post: by
14 posts views Thread by sridhar | last post: by
4 posts views Thread by gregpinero | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.