Notices
Non Scooby Related Anything Non-Scooby related

VB sample code

Thread Tools
 
Search this Thread
 
Old 27 June 2001, 04:01 PM
  #1  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

Can anyone send me a bit of vb code to access the inbox of a particular outlook 2000 mailbox and also the property tags for the message items within the folder so I can read them too?

doesn't matter if it's mapi/cdo or outlook.application code.

Many thanks
Fosters
Michael.toye@bmw.co.uk
Old 27 June 2001, 04:27 PM
  #2  
Neil Micklethwaite
Scooby Regular
 
Neil Micklethwaite's Avatar
 
Join Date: Dec 1998
Posts: 1,046
Likes: 0
Received 0 Likes on 0 Posts
Post

Hi Michael

Have you got MSDN , that certainly had CDO - Outlook Mailbox processing in it somewhere.

I'll have a dig if you haven't got access to one.
Old 28 June 2001, 11:41 AM
  #3  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

Seeing as I had to write it myself!!!

If you ever need to update an access table with the messages from an outlook folder then here's the code. I will enhance mine to check, transfer and then remove the messages from the inbox on a timer. (this is for a support desk facility)

Dim oOutlook As New Outlook.Application
Dim oNameSpace As Object
Dim oFolder As MAPIFolder
Dim oInbox As MAPIFolder
Dim Cn As New ADODB.Connection
Function OpenConn2MailboxDB() As Boolean
Dim sCn As String
sCn = "Driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=c:MISFAMailbox.mdb;" & _
"uid=;pwd=;"
Cn.Open sCn
OpenConn2MailboxDB = IIf(Cn.State = 0, False, True)

End Function
Sub CloseConn()
Cn.Close
End Sub
Private Sub Form_Load()
Dim oItem As MailItem
Dim x As Integer
Dim RC As Boolean
Dim RS As New ADODB.Recordset
Dim sSQL As String

RC = OpenConn2MailboxDB

Set oNameSpace = oOutlook.GetNamespace("MAPI")
Set oFolder = oNameSpace.Folders("Mailbox - MIS Finance & Admin Helpdesk")
Set oInbox = oFolder.Folders("Inbox")
'use oFolder.Folders("Inbox").Folders("sub folder name")
'for messages in a subfolder of a main folder

For x = 1 To oInbox.Items.Count
sSQL = "insert into Inbox (Received, Subject, Frm, Bdy) " & _
"values (" & _
"'" & oInbox.Items(x).SentOn & "', " & _
"'" & RQ(oInbox.Items(x).Subject) & "', " & _
"'" & RQ(oInbox.Items(x).SenderName) & "', " & _
"'" & RQ(oInbox.Items(x).Body) & "'" & _
");"
RS.Open sSQL, Cn
Set RS = Nothing
Next x

CloseConn
End Sub
Function RQ(sIn As String) As String
RQ = Replace(sIn, "'", "''")
End Function
Old 28 June 2001, 11:43 AM
  #4  
Fosters
Scooby Regular
Thread Starter
 
Fosters's Avatar
 
Join Date: Jul 2000
Location: Islington
Posts: 2,145
Likes: 0
Received 0 Likes on 0 Posts
Post

oh yeah, you need references to ADO and Microsoft Outlook in your vb project
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Darrell@Scoobyworx
Trader Announcements
26
30 January 2024 01:27 PM
Abx
Subaru
22
09 January 2016 05:42 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
Sam Witwicky
Engine Management and ECU Remapping
17
13 November 2015 10:49 AM



Quick Reply: VB sample code



All times are GMT +1. The time now is 07:07 PM.