View Single Post
  #4  
Old August 28th 08, 10:12 PM posted to microsoft.public.outlook.program_vba
dch3
external usenet poster
 
Posts: 105
Default Reading MailItem properties outside of Outlook

Ya' didn't say that. Why not just use an Outlook Public Folder for the
messages?

But wait...a hot babe just walked by and inspired me...

Why not setup custom code the ThisOutlookSession whereby a user has the
ability to programically save the file as a *.msg file and at the same time
capture the various properties that you're looking for and append them to an
underlying Access database. You'd then be able to search for messages via an
Access front end and open them from the same. If the message can be
predictably identified as belonging to the project, you could have the code
execute automatically.

"Ken Warthen" wrote:


dch3,

Actually I'm not snooping around in an Outlook folder (Set targetCalendar =
nms.GetDefaultFolder(WMS_olFolderCalendar) ). The folder is a project folder
on a server where messages related to a project are dragged and dropped. I
have a listview control on an Access form where the user can view the .msg
files, but I'd like to add information to the listview control like subject,
from, to, etc., so the messages can be better identified.

Ken

"dch3" wrote:

The code below is a sample to get you started. It retreives all items with a
specific value in a custom property and deletes it. I've added comments where
you'll start your own snooping...

Private Function deleteOutlookAppointmentByTransportId(lngTransport ID As Long)

'Use generic objects to avoid having to set a reference
Dim objOutlook As Object
Dim nms As Object
'Dim objOutlook As Outlook.Application
'Dim nms As Outlook.NameSpace
'Dim targetCalendar As Outlook.MAPIFolder
'Dim targetItems As Outlook.Items
'Dim targetAppointment As Outlook.AppointmentItem
Dim targetCalendar As Object
Dim targetItems As Object
Dim i As Integer
Dim aOutlookEntryIds()
Dim targetAppointment As Object
Dim strFilter As String
Dim intTargetItemCount As Integer

'Create the Outlook objects that we'll be working with here
Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
'Select the folder that we're snooping around in
Set targetCalendar = nms.GetDefaultFolder(WMS_olFolderCalendar)

'Get the items that we're working with based on a specific criteria
strFilter = "[dbAccessId]=" & Chr(34) & lngTransportID & Chr(34)
Set targetItems = targetCalendar.Items.Restrict(strFilter)

ReDim aOutlookEntryIds(targetItems.Count)
For i = 1 To targetItems.Count
Debug.Print i
aOutlookEntryIds(i) = targetItems(i).EntryID
Next i

intTargetItemCount = targetItems.Count

'Loop through the items and print their properties (I accidently deleted
a For i ... Next loop here but its easy to add it back in
Set targetAppointment = nms.GetItemFromID(aOutlookEntryIds(i))
Debug.Print targetAppointment.UserProperties(1),
targetAppointment.Start, targetAppointment.Subject
targetAppointment.Delete
Debug.Print "Appoint ID: " & aOutlookEntryIds(i) & " Deleted"

Set targetItems = Nothing
Set targetCalendar = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Function


"Ken Warthen" wrote:

I'm having difficulty creating a function to retrieve the properties, such as
To, From, Subject, Date, from Outlook MailItems (.msg files) that are stored
on a server outside of Outlook. I have a form in an Access 2007 application
where the properties will be accessed by users. I wasn't sure if I should
post here or in the MS Access forum, but thought there would be more Outlook
expertise here. Any help or direction would be greatly appreciated.

Ken

Ads