Dougalsworld
Paul
- Local time
- Yesterday, 18:42
- Joined
- Jul 29, 2005
- Messages
- 62
High folks,
Essentially I have a database thatsends out meeting requests as an AppointmentItem. The replys are automatically sent to a certain folder in my inbox.
I also found a second bit of code that pulls mail details from a chosen folder through to access.
My problem is as follows, the code (shown below) pulls standard email no problem at all, but I can't make it pull Meeting replies.
On the code below I have tried changing the highlighted phrases to AppointmentItem to no avail...any ideas?
Dim appOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
'itm declared as object because a folder can contain different
'types of objects
Dim itm As Object
Dim msg As Outlook.MailItem
Dim strMessage As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim prj As Object
Dim lngItemCount As Long
'Determine whether Outlook is running
Set appOutlook = GetObject(, "Outlook.Application")
'Let the user select an Outlook folder to process
Set nms = appOutlook.GetNamespace("MAPI")
Set fld = nms.PickFolder
If fld Is Nothing Then
GoTo ErrorHandlerExit
End If
Debug.Print "Folder default item type: " & fld.DefaultItemType
If fld.DefaultItemType <> olMailItem Then
MsgBox "Folder does not contain mail messages; exiting"
GoTo ErrorHandlerExit
End If
lngItemCount = fld.Items.Count
Debug.Print "Number of messages in folder: " _
& lngItemCount
If lngItemCount = 0 Then
MsgBox "No messages in selected folder; exiting:"
GoTo ErrorHandlerExit
End If
'Process items in selected folder
strSQL = "DELETE * FROM tblOutlookMail"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblOutlookMail")
For Each itm In fld.Items
If itm.Class = olMail Then
Set msg = itm
With rst
.AddNew
!Subject = msg.Subject
!Body = msg.Body
!CC = msg.CC
!BCC = msg.BCC
!Sent = msg.SentOn
!From = msg.SenderName
!Category = msg.Categories
.Update
End With
End If
Next itm
rst.Close
Essentially I have a database thatsends out meeting requests as an AppointmentItem. The replys are automatically sent to a certain folder in my inbox.
I also found a second bit of code that pulls mail details from a chosen folder through to access.
My problem is as follows, the code (shown below) pulls standard email no problem at all, but I can't make it pull Meeting replies.
On the code below I have tried changing the highlighted phrases to AppointmentItem to no avail...any ideas?
Dim appOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
'itm declared as object because a folder can contain different
'types of objects
Dim itm As Object
Dim msg As Outlook.MailItem
Dim strMessage As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim prj As Object
Dim lngItemCount As Long
'Determine whether Outlook is running
Set appOutlook = GetObject(, "Outlook.Application")
'Let the user select an Outlook folder to process
Set nms = appOutlook.GetNamespace("MAPI")
Set fld = nms.PickFolder
If fld Is Nothing Then
GoTo ErrorHandlerExit
End If
Debug.Print "Folder default item type: " & fld.DefaultItemType
If fld.DefaultItemType <> olMailItem Then
MsgBox "Folder does not contain mail messages; exiting"
GoTo ErrorHandlerExit
End If
lngItemCount = fld.Items.Count
Debug.Print "Number of messages in folder: " _
& lngItemCount
If lngItemCount = 0 Then
MsgBox "No messages in selected folder; exiting:"
GoTo ErrorHandlerExit
End If
'Process items in selected folder
strSQL = "DELETE * FROM tblOutlookMail"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblOutlookMail")
For Each itm In fld.Items
If itm.Class = olMail Then
Set msg = itm
With rst
.AddNew
!Subject = msg.Subject
!Body = msg.Body
!CC = msg.CC
!BCC = msg.BCC
!Sent = msg.SentOn
!From = msg.SenderName
!Category = msg.Categories
.Update
End With
End If
Next itm
rst.Close
Last edited: