WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Reading MailItem properties outside of Outlook

 
   Home -> Office -> Programming VBA RSS
Next:  Attachment labels in Outlook 2003  
Author Message
Ken Warthen

External


Since: Nov 09, 2007
Posts: 18



(Msg. 1) Posted: Thu Aug 28, 2008 7:32 am
Post subject: Reading MailItem properties outside of Outlook
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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 to top
Login to vote
dch3

External


Since: Jul 28, 2006
Posts: 92



(Msg. 2) Posted: Thu Aug 28, 2008 1:19 pm
Post subject: RE: Reading MailItem properties outside of Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" 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
Back to top
Login to vote
Ken Warthen

External


Since: Nov 09, 2007
Posts: 18



(Msg. 3) Posted: Thu Aug 28, 2008 1:42 pm
Post subject: RE: Reading MailItem properties outside of Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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(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" 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
Back to top
Login to vote
dch3

External


Since: Jul 28, 2006
Posts: 92



(Msg. 4) Posted: Thu Aug 28, 2008 2:12 pm
Post subject: RE: Reading MailItem properties outside of Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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(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" 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
Back to top
Login to vote
Ken Warthen

External


Since: Nov 09, 2007
Posts: 18



(Msg. 5) Posted: Thu Aug 28, 2008 2:21 pm
Post subject: RE: Reading MailItem properties outside of Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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(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" 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
Back to top
Login to vote
dch3

External


Since: Jul 28, 2006
Posts: 92



(Msg. 6) Posted: Thu Aug 28, 2008 2:35 pm
Post subject: RE: Reading MailItem properties outside of Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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/utility-components/aspose.network-...-.net/o

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-ft...ct70812

"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(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" 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
Back to top
Login to vote
Dmitry Streblechenko

External


Since: Nov 23, 2003
Posts: 1122



(Msg. 7) Posted: Tue Sep 02, 2008 10:00 am
Post subject: Re: Reading MailItem properties outside of Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <dch3 DeleteThis @discussions.microsoft.com> wrote in message
news:372D8BDB-2AF3-49AB-B231-A1655571D76E@microsoft.com...
> 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/utility-components/aspose.network-...-.net/o
>
> 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-ft...ct70812
>
> "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(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" 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
Back to top
Login to vote
dch3

External


Since: Jul 28, 2006
Posts: 92



(Msg. 8) Posted: Tue Sep 02, 2008 2:40 pm
Post subject: Re: Reading MailItem properties outside of Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <dch3 RemoveThis @discussions.microsoft.com> wrote in message
> news:372D8BDB-2AF3-49AB-B231-A1655571D76E@microsoft.com...
> > 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/utility-components/aspose.network-...-.net/o
> >
> > 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-ft...ct70812
> >
> > "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(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" 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
>
>
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET