A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Reading MailItem properties outside of Outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 28th 08, 03:32 PM posted to microsoft.public.outlook.program_vba
Ken Warthen
external usenet poster
 
Posts: 12
Default Reading MailItem properties outside of Outlook

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
  #2  
Old August 28th 08, 09:19 PM posted to microsoft.public.outlook.program_vba
dch3
external usenet poster
 
Posts: 105
Default Reading MailItem properties outside of Outlook

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

  #3  
Old August 28th 08, 09:42 PM posted to microsoft.public.outlook.program_vba
Ken Warthen
external usenet poster
 
Posts: 12
Default Reading MailItem properties outside of Outlook


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

  #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

  #5  
Old August 28th 08, 10:21 PM posted to microsoft.public.outlook.program_vba
Ken Warthen
external usenet poster
 
Posts: 12
Default Reading MailItem properties outside of Outlook


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" wrote:

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

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

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/...le-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/O...ict708121.html

"Ken Warthen" wrote:


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" wrote:

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

  #7  
Old September 2nd 08, 06:00 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Reading MailItem properties outside of Outlook

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" wrote in message
...
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/...le-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/O...ict708121.html

"Ken Warthen" wrote:


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" wrote:

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



  #8  
Old September 2nd 08, 10:40 PM posted to microsoft.public.outlook.program_vba
dch3
external usenet poster
 
Posts: 105
Default Reading MailItem properties outside of Outlook

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" wrote:

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" wrote in message
...
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/...le-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/O...ict708121.html

"Ken Warthen" wrote:


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" wrote:

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




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to MailItem properties before opening new inspector ? Marcin Add-ins for Outlook 8 April 25th 08 07:50 PM
Outlook 2003- named properties v/s user properties ? newToOutlookProgramming Add-ins for Outlook 2 May 18th 07 06:38 PM
event handler for changes to TO CC and BCC properties of mailitem epsilon_9 Outlook and VBA 3 January 15th 07 04:14 PM
Reading properties of encrypted e-mails Sanjay Singh Outlook and VBA 0 March 10th 06 05:12 AM
How can I create a MailItem that displays like a received MailItem ? Clive Outlook - Using Forms 0 February 27th 06 05:14 PM


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2014 Outlook Banter.
The comments are property of their posters.