Reading MailItem properties outside of Outlook

  • Thread starter Thread starter Ken Warthen
  • Start date Start date
K

Ken Warthen

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
 
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(lngTransportID 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
 
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 said:
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(lngTransportID 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 said:
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
 
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 said:
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 said:
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(lngTransportID 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 said:
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
 
Public Folders would be too logical. These are engineers who have a process
that they don't want to change. I've added a feature whereby the user can
right click on a message from within Outlook and one of the options on the
pop up menu is "Move selected file to Project folder." This runs code from
within the ThisOutlookSession that uses the SaveAs method to save the message
to a user selected project folder and then deletes the file from Outlook.
All this is working pretty well. Now I'd like to be able to read some of the
properties of the moved message files from my Access form.

Ken

dch3 said:
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 said:
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 said:
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(lngTransportID 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


:

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
 
I'd go with my idea of getting the information in the same step that you're
saving the file. However, this looks promissing...

http://www.aspose.com/documentation...network-for-.net/outlook-msg-file-viewer.html

Its a product that supplies a class through which you can read the .msg
properties. There's a reference to VB.NET which makes me think that they
*might* have something thats VBA compatible.

I did find this post that suggest that you could use
Namespace.CreateItemFromTemplate to essentially use the .msg file as a
template to create a new MailItem thus exposing the various properties.
http://help.lockergnome.com/office/Open-msg-File-Attachment-details-ftopict708121.html

Ken Warthen said:
Public Folders would be too logical. These are engineers who have a process
that they don't want to change. I've added a feature whereby the user can
right click on a message from within Outlook and one of the options on the
pop up menu is "Move selected file to Project folder." This runs code from
within the ThisOutlookSession that uses the SaveAs method to save the message
to a user selected project folder and then deletes the file from Outlook.
All this is working pretty well. Now I'd like to be able to read some of the
properties of the moved message files from my Access form.

Ken

dch3 said:
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 said:
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

:

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(lngTransportID 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


:

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
 
Namespace.CreateItemFromTemplate will wipe out all the sender related
propertie and most dates.
You can use Extended MAPI (OpenIMsgOnIStg etc) to read an MSG file (C++ or
Delphi, no VB or .Net) or <plug> Redemption which exposes
RDOSession.GetMessageFromMsgFile method -
http://www.dimastr.com/redemption/rdo/rdosession.htm </plug>

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
dch3 said:
I'd go with my idea of getting the information in the same step that
you're
saving the file. However, this looks promissing...

http://www.aspose.com/documentation...network-for-.net/outlook-msg-file-viewer.html

Its a product that supplies a class through which you can read the .msg
properties. There's a reference to VB.NET which makes me think that they
*might* have something thats VBA compatible.

I did find this post that suggest that you could use
Namespace.CreateItemFromTemplate to essentially use the .msg file as a
template to create a new MailItem thus exposing the various properties.
http://help.lockergnome.com/office/Open-msg-File-Attachment-details-ftopict708121.html

Ken Warthen said:
Public Folders would be too logical. These are engineers who have a
process
that they don't want to change. I've added a feature whereby the user
can
right click on a message from within Outlook and one of the options on
the
pop up menu is "Move selected file to Project folder." This runs code
from
within the ThisOutlookSession that uses the SaveAs method to save the
message
to a user selected project folder and then deletes the file from Outlook.
All this is working pretty well. Now I'd like to be able to read some of
the
properties of the moved message files from my Access form.

Ken

dch3 said:
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.

:


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

:

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(lngTransportID 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


:

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
 
There are some on the internet who believe that Redemption is actually the
precursor to Skynet....which I personally don't believe - .NET is.

Dmitry Streblechenko said:
Namespace.CreateItemFromTemplate will wipe out all the sender related
propertie and most dates.
You can use Extended MAPI (OpenIMsgOnIStg etc) to read an MSG file (C++ or
Delphi, no VB or .Net) or <plug> Redemption which exposes
RDOSession.GetMessageFromMsgFile method -
http://www.dimastr.com/redemption/rdo/rdosession.htm </plug>

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
dch3 said:
I'd go with my idea of getting the information in the same step that
you're
saving the file. However, this looks promissing...

http://www.aspose.com/documentation...network-for-.net/outlook-msg-file-viewer.html

Its a product that supplies a class through which you can read the .msg
properties. There's a reference to VB.NET which makes me think that they
*might* have something thats VBA compatible.

I did find this post that suggest that you could use
Namespace.CreateItemFromTemplate to essentially use the .msg file as a
template to create a new MailItem thus exposing the various properties.
http://help.lockergnome.com/office/Open-msg-File-Attachment-details-ftopict708121.html

Ken Warthen said:
Public Folders would be too logical. These are engineers who have a
process
that they don't want to change. I've added a feature whereby the user
can
right click on a message from within Outlook and one of the options on
the
pop up menu is "Move selected file to Project folder." This runs code
from
within the ThisOutlookSession that uses the SaveAs method to save the
message
to a user selected project folder and then deletes the file from Outlook.
All this is working pretty well. Now I'd like to be able to read some of
the
properties of the moved message files from my Access form.

Ken

:

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.

:


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

:

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(lngTransportID 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


:

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
 
Back
Top