A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to log into my mailbox on Exchange



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 10th 09, 01:40 PM posted to microsoft.public.outlook.program_addins
Derick Swart
external usenet poster
 
Posts: 10
Default How to log into my mailbox on Exchange

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
  #2  
Old February 10th 09, 03:09 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to log into my mailbox on Exchange

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


  #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



  #4  
Old February 10th 09, 07:10 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to log into my mailbox on Exchange

You never want to install Outlook on an Exchange box, it's a real good way
to mess up both.

Running on a server, Outlook code really isn't a good idea. First you have
to have Outlook installed there. Second, the Outlook code there has to run
in a different context than it would on a client, so you need to have
permissions and profiles set up for every mailbox you want to log into, or
you need the profile on the server to have permissions to log into all the
relevant mailboxes and use the NameSpace.GetSharedDefaultFolder() method to
access the alternate mailboxes.

If you use different profiles the code must log into Outlook, prompt for
profile to use, do its work, then exit Outlook and log into another mailbox.

Using GetSharedDefaultFolder() allows you do one Outlook logon using the
existing Outlook profile there and then use the method to access default
folders in those other mailboxes.

--
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
...[i]
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;
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;
}
}
}


  #5  
Old February 11th 09, 12:04 AM posted to microsoft.public.outlook.program_addins
Derick Swart
external usenet poster
 
Posts: 10
Default How to log into my mailbox on Exchange

Dear Ken,

Thank you for the advice.

Sorry if I am slow, but essentially you are saying that the
GetSharedDefaultFolder() method is the best way to achieve this, but not
running on the same box as Exchange?

Regards,
Derick

"Ken Slovak - [MVP - Outlook]" wrote in message
...[i]
You never want to install Outlook on an Exchange box, it's a real good way
to mess up both.

Running on a server, Outlook code really isn't a good idea. First you have
to have Outlook installed there. Second, the Outlook code there has to run
in a different context than it would on a client, so you need to have
permissions and profiles set up for every mailbox you want to log into, or
you need the profile on the server to have permissions to log into all the
relevant mailboxes and use the NameSpace.GetSharedDefaultFolder() method
to access the alternate mailboxes.

If you use different profiles the code must log into Outlook, prompt for
profile to use, do its work, then exit Outlook and log into another
mailbox.

Using GetSharedDefaultFolder() allows you do one Outlook logon using the
existing Outlook profile there and then use the method to access default
folders in those other mailboxes.

--
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
...
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;
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;
}
}
}



  #6  
Old February 11th 09, 02:21 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to log into my mailbox on Exchange

Yes that's correct.

--
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
...
Dear Ken,

Thank you for the advice.

Sorry if I am slow, but essentially you are saying that the
GetSharedDefaultFolder() method is the best way to achieve this, but not
running on the same box as Exchange?

Regards,
Derick


  #7  
Old February 11th 09, 05:20 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How to log into my mailbox on Exchange

Unless you are using WebDAV or Extended MAPI (or Redemption).

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Ken Slovak - [MVP - Outlook]" wrote in message
...
Yes that's correct.

--
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
...
Dear Ken,

Thank you for the advice.

Sorry if I am slow, but essentially you are saying that the
GetSharedDefaultFolder() method is the best way to achieve this, but not
running on the same box as Exchange?

Regards,
Derick




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect Exchange/Mailbox details Simon Outlook - General Queries 2 April 16th 08 06:50 AM
Copy calendar from PST to Exchange mailbox? Tom Outlook - Installation 2 December 17th 07 07:50 PM
Accessing another Exchange mailbox SteveB Outlook and VBA 2 June 15th 06 12:46 PM
Exchange Mailbox server prohibit from sending when reach mailbox size limit Milly Staples [MVP - Outlook] Outlook - General Queries 1 February 24th 06 06:41 PM
Outlook 2003 / Exchange and 2nd mailbox... Ivan T. Williams Outlook - General Queries 1 January 27th 06 01:43 PM


All times are GMT +1. The time now is 08:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.