|
-
Aug 1st, 2005, 03:34 AM
#1
Thread Starter
Fanatic Member
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
-
Aug 11th, 2005, 03:20 AM
#2
Thread Starter
Fanatic Member
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:
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
' Note: Windows Form Designer Generated Code Omitted
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As New DataSet
Dim dt As DataTable
Try
'SELECT Subject, Contents FROM Inbox
Dim da As New OleDbDataAdapter("SELECT * FROM Inbox", _
"Provider=Microsoft.Jet.OLEDB.4.0;Outlook 9.0;" & _
"MAPILEVEL=Mailbox - [insert mailbox name here e.g. Paul Jones]|;PROFILE=MS Exchange Settings;" & _
"TABLETYPE=0;DATABASE=C:\WINNT\Temp")
da.Fill(ds, "Outlook")
dt = ds.Tables("Outlook")
DataGrid1.DataSource = dt
Catch exc As OleDbException
Dim OleDBError1 As OleDbError
For Each OleDBError1 In exc.Errors
Console.WriteLine(OleDBError1.Message)
Next
End Try
End Sub
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|