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

Outlook Macro to get Exchange Info from Mail



 
 
Thread Tools Search this Thread Display Modes
  #11  
Old April 22nd 10, 07:59 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook Macro to get Exchange Info from Mail

I don't have CDO 1.21 installed here, so the script below uses Redemption


set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
for each Item in Application.ActiveExplorer.Selection
set RDOItem = Session.GetMessagefromID(Item.EntryID)
set Sender = RDOItem.Sender
if not (Sender Is Nothing) Then
MsgBox Sender.City
end if
next

The next script is using CDO 1.21, but I did not have a chance to actually
test it

set Session = CreateObject("MAPI.Session")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
for each Item in Application.ActiveExplorer.Selection
set CDOItem = Session.GetMessage(Item.EntryID)
set Sender = CDOItem.Sender
if not (Sender Is Nothing) Then
MsgBox Sender.City
end if
next

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"_M_a_t_t_" wrote in message
...
Thanks for the update Dmitry, however I do not understand what you are
refering to nor how to do what you have stated (I say that I need an
example
previously) ..... Any chance you can post a small example?



Ads
  #12  
Old April 23rd 10, 09:33 AM posted to microsoft.public.outlook.program_vba
_M_a_t_t_[_2_]
external usenet poster
 
Posts: 12
Default Outlook Macro to get Exchange Info from Mail

Thanks Dmitry, regretfully the CDO example doesn't work... I get an error on
MAPIOBJECT: "Method or data member not found (Error 461)"....

  #13  
Old April 26th 10, 08:08 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook Macro to get Exchange Info from Mail

Do you get that error on reading the Application.Session.MAPIOBJECT or
setting the Session.MAPIOBJECT property.
Where does your code run?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"_M_a_t_t_" wrote in message
...
Thanks Dmitry, regretfully the CDO example doesn't work... I get an error
on
MAPIOBJECT: "Method or data member not found (Error 461)"....



  #14  
Old April 27th 10, 10:53 AM posted to microsoft.public.outlook.program_vba
_M_a_t_t_[_2_]
external usenet poster
 
Posts: 12
Default Outlook Macro to get Exchange Info from Mail

I get the error on:
Session.MAPIOBJECT = Application.Session.MAPIOBJECT

Regretfully the help isn't 'helpful' here, since I can't find any
information about this, or what would be 'correct'.....

  #15  
Old April 28th 10, 01:21 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook Macro to get Exchange Info from Mail

That line contains two statements. One is reading the property. Another one
is setting it. Can you break that line in two to see which one fails?

set temp = Application.Session.MAPIOBJECT
Session.MAPIOBJECT = temp

Is this Access? If, Session intrinsic variable points to an Access object.
Rename the Session variable in the script to somethign like CDOSession.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"_M_a_t_t_" wrote in message
...
I get the error on:
Session.MAPIOBJECT = Application.Session.MAPIOBJECT

Regretfully the help isn't 'helpful' here, since I can't find any
information about this, or what would be 'correct'.....



  #16  
Old April 30th 10, 06:31 AM posted to microsoft.public.outlook.program_vba
_M_a_t_t_[_2_]
external usenet poster
 
Posts: 12
Default Outlook Macro to get Exchange Info from Mail

Again, where does your code run?
I'm trying to get this working on Outlook 2003 (11.8313.8221) SP3.

Another words, Outlook VBA (Alt-F11 in Outlook).
  #17  
Old April 30th 10, 07:39 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook Macro to get Exchange Info from Mail

Session is also an intrinsic variable in VBA. Try the following (it does
work)

PR_LOCALITY = &H3A27001E

Set cdoSession = CreateObject("MAPI.Session")

Set temp = Application.Session.MAPIOBJECT

cdoSession.MAPIOBJECT = temp

For Each Item In Application.ActiveExplorer.Selection

Set CDOItem = cdoSession.GetMessage(Item.EntryID)

Set Sender = CDOItem.Sender

If Not (Sender Is Nothing) Then

Set Field = Sender.Fields.Item(PR_LOCALITY)

If Not (Field Is Nothing) Then

MsgBox Field.Value

End If

End If

Next


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"_M_a_t_t_" wrote in message
...
Again, where does your code run?

I'm trying to get this working on Outlook 2003 (11.8313.8221) SP3.

Another words, Outlook VBA (Alt-F11 in Outlook).



  #18  
Old May 5th 10, 09:42 AM posted to microsoft.public.outlook.program_vba
_M_a_t_t_[_2_]
external usenet poster
 
Posts: 12
Default Outlook Macro to get Exchange Info from Mail

Hopfully this reply is posted. Tried several time, and for some reason its
not posting.

When I run the code you posted above I get:
Compile error:

Assignment to constant not permitted

on this line:
Set CdoSession = CreateObject("MAPI.Session")
  #19  
Old May 5th 10, 02:50 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Macro to get Exchange Info from Mail

Try setting a reference to CDO.DLL in the references for your VBA project.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"_M_a_t_t_" wrote in message
...
Hopfully this reply is posted. Tried several time, and for some reason its
not posting.

When I run the code you posted above I get:
Compile error:

Assignment to constant not permitted

on this line:
Set CdoSession = CreateObject("MAPI.Session")


  #20  
Old May 6th 10, 08:17 AM posted to microsoft.public.outlook.program_vba
_M_a_t_t_[_2_]
external usenet poster
 
Posts: 12
Default Outlook Macro to get Exchange Info from Mail

Hi Ken,

Try setting a reference to CDO.DLL in the references for your VBA project.

I have this already:
Microsoft CDO 1.21 Library
C:\Program Files\Common Files\System\MSMAPI\1033\CDO.DLL

I'm starting to think this isn't possible.......

 




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
Outlook Contacts Macro to Change Info Jason Outlook and VBA 1 November 14th 08 12:57 AM
Macro to rename Subject of E-mail on exchange server(2007) Ryan Arnold Outlook and VBA 4 October 6th 08 04:30 AM
outlook 2003 macro to extract calendar appointment info to Excel CPOjoe Outlook - Calandaring 3 July 15th 08 05:04 PM
retrieving Outlook user info from Word macro IndianSummer Outlook and VBA 1 September 29th 07 01:05 AM
Importing Outlook Alias info into an excel 2003 macro fidgitthedigit Outlook and VBA 4 May 31st 06 05:22 PM


All times are GMT +1. The time now is 04:54 PM.


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