Results 1 to 2 of 2

Thread: Connect to Outlook Mailbox

  1. #1

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Connect to Outlook Mailbox

    Does anyone know how to connect to an outlook mailbox with asp.net?

    Any help will be greatly appreciated

    Cheers Al

  2. #2

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Re: Connect to Outlook Mailbox

    Ok, I've managed to do it, so thought I should post the solution for completeness.
    This snippet is for vb.Net but could easily be modded for ASP.Net, which I'll be doing at some point.

    You need two things to make this code work -
    The mailbox name
    The local Exchange/Outlook profile

    You can get the name of the profile and the mailbox name by opening the Control Panel and double clicking the Mail icon. You should see the profiles (by default there is just one, but you can create more) that are defined on the machine. It will probably be named something like "MS Exchange Settings" or "Outlook". Click the
    Delivery tab to see the list of available mailboxes. Your mailbox name is in the "Deliver new mail to the following location" box. For Exchange servers, the mailbox name typically looks like "Mailbox - James Smith" or "Personal Folders", depending on if the mail is being delivered to a server or a local store.

    VB Code:
    1. Imports System.Data.OleDb
    2.  
    3. Public Class Form1
    4.     Inherits System.Windows.Forms.Form
    5.    
    6.    ' Note: Windows Form Designer Generated Code Omitted
    7.  
    8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    9.         Dim ds As New DataSet
    10.         Dim dt As DataTable
    11.  
    12.         Try
    13.             'SELECT Subject, Contents FROM Inbox
    14.             Dim da As New OleDbDataAdapter("SELECT * FROM Inbox", _
    15.                                             "Provider=Microsoft.Jet.OLEDB.4.0;Outlook 9.0;" & _
    16.                                             "MAPILEVEL=Mailbox - [insert mailbox name here e.g. Paul Jones]|;PROFILE=MS Exchange Settings;" & _
    17.                                             "TABLETYPE=0;DATABASE=C:\WINNT\Temp")
    18.  
    19.             da.Fill(ds, "Outlook")
    20.             dt = ds.Tables("Outlook")
    21.             DataGrid1.DataSource = dt
    22.         Catch exc As OleDbException
    23.             Dim OleDBError1 As OleDbError
    24.             For Each OleDBError1 In exc.Errors
    25.                 Console.WriteLine(OleDBError1.Message)
    26.             Next
    27.         End Try
    28.     End Sub
    29.  
    30. End Class

    source http://www.dotnet247.com/247referenc.../14/72031.aspx
    Last edited by aconybeare; Aug 11th, 2005 at 03:35 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width