View Single Post
  #3  
Old February 10th 09, 05:53 PM posted to microsoft.public.outlook.program_addins
Derick Swart
external usenet poster
 
Posts: 10
Default How to log into my mailbox on Exchange

Thanks Ken. Sorry for the poor formulation.

I am working with Outlook 2007 items via an intranet application (Asp.NET
3.5). I have read Microsoft's cautionery notes.

On my own machine it works fine (snippet below), but when deployed to the
server it is obviously not going to work as is currently the case. I would
have to log onto Exchange, I suppose?

(Outlook is not installed on the Exchange box - our platform people tell me
this is not possible).

Thank you for your time.

Regards,
Derick

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Microsoft.Office.Interop.Outlook.Application app = null;
Microsoft.Office.Interop.Outlook._NameSpace ns = null;
Microsoft.Office.Interop.Outlook.MailItem item = null;
Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null;
Microsoft.Office.Interop.Outlook.MAPIFolder subFolder = null;

try
{
app = new Microsoft.Office.Interop.Outlook.Application();
ns = app.GetNamespace("MAPI");
ns.Logon(null, null, false, false);

inboxFolder =
ns.GetDefaultFolder(Microsoft.Office.Interop.Outlo ok.OlDefaultFolders.olFolderInbox);
subFolder = inboxFolder.Folders["Persoonlik"];
//folder.Folders[1]; also works
Response.Write("Folder Name: " + subFolder.Name + " EntryId" +
subFolder.EntryID);
Response.Write("Num Items: " +
subFolder.Items.Count.ToString());

for (int i = 1; i = 6; i++) //i = subFolder.Items.Count
{
item =
(Microsoft.Office.Interop.Outlook.MailItem)subFold er.Items[i];
Response.Write("Item: " + i.ToString());
Response.Write("Subject: " + item.Subject);
Response.Write("Sent: " + item.SentOn.ToLongDateString() +
"," + item.SentOn.ToLongTimeString());
Response.Write("Categories: " + item.Categories);
Response.Write("Body: " + item.Body);
Response.Write("HTMLBody: " + item.HTMLBody);
}
}
catch (System.Runtime.InteropServices.COMException ex)
{
Response.Write(ex.ToString());
}
finally
{
ns = null;
app = null;
inboxFolder = null;
}
}
}
"Ken Slovak - [MVP - Outlook]" wrote in message
...
Using what language and API?

Where is the code running, is Outlook installed or is this a machine where
Outlook isn't installed?

This is your own mailbox?

What version of Outlook if Outlook is installed?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Derick Swart" wrote in message
...
Hi there,

Can someone kindly assist me with a code sample or link showing how to
log into and get to mailitems on an Exchange server? We run AD as well.

Regards,
Derick



Ads