G
Guest
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);
}
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);
}