HOWTO: Access Message Property Not Exposed by Active Messaging

Last reviewed: January 27, 1998
Article ID: Q174211
The information in this article applies to:
  • Collaboration Data Objects (CDO), version 1.1

SUMMARY

Active Messaging is a set of wrappers around Extended MAPI objects. In many cases Active Messaging exposes only a small subset of the properties actually present on the underlying Extended MAPI object.

This article provides a sample demonstrating how to access these unexposed properties.

MORE INFORMATION

Please note that while most properties can be exposed using their Property Tags, not all of them are usable by Visual Basic. Some fields require certain forms of data that Visual Basic cannot supply (such as a structure containing an array or structures).

  1. Open a new Project in Visual Basic.

  2. Add a Reference to the file Olemsg32.dll. (If it is not on your system in either the system or system32 subdirectory, the Active Messaging Library is not installed.)

  3. Paste the following code sample into a new Visual Basic Form containing three Command Buttons:

          Public objSession As MAPI.Session
          Public objMsg As Message
    

          Private Sub Form_Load()
    
              'Dim objects, then create and logon to session
              Set objSession = CreateObject("MAPI.Session")
              objSession.Logon "MyProfileNameHere"
          End Sub
    
          Private Sub Command1_Click()
              'This sample assumes you have at least one msg in your Inbox
              Set objMsg = objSession.Inbox.Messages.GetFirst()
    
              'This is where we >>look at<< unexposed properties by referencing
              'them via their Property Tag. First, we will just look at one by
              'referencing a constant defined in Olemsg32.dll. Then we look at
              'the same property by referencing the Property Tag value. Note:
              'The constants are specific to the 32-bit Active Messaging
              'Library.
              MsgBox "Class (using Constant): " & _
                objMsg.Fields(ActMsgPR_MESSAGE_CLASS)
              MsgBox "Class (using PropTag): " & _
                objMsg.Fields(&H1A001E)
              MsgBox "Flags (using Constant): " & _
                objMsg.Fields(ActMsgPR_MESSAGE_FLAGS)
              MsgBox "Flags (using PropTag): " & _
                objMsg.Fields(&HE070003)
          End Sub
    
          Private Sub Command2_Click()
              'NOTE: The code sample in Command2_Click demonstrates how to send
              'messages on behalf of another user.  It must be noted here, that
              'this process will fail unless the user has given you permission
              'to do this on their Exchange Server Account.
    
              'Sending on behalf of another user
              '---------------------------------
              'You can also use Property Tags to expose unexposed properties of
              'a newly created Message to add functionality supported by the
              'underlying MAPI subsystem that is not directly supported by
              'Active Messaging. For example, the following code will enable
              'you to send a message on another users behalf (aka - "Sent
              'Representing"):
    
              'Dim new Message and Recip objects
              Dim objMessage As Message
              Dim objRecip As Recipient
    
              'Add a new Message to the Outbox
              Set objMessage = objSession.Outbox.Messages.Add
    
              'Get a new valid AddressEntry object
              '  >>for the person you will send on behalf of<<
              Set objRecip = objMessage.Recipients.Add
              objRecip.Name = "JoeManager"
              objRecip.Type = 1
              objRecip.Resolve
    
              'Add the needed fields to the new Message then populate with
              'values from "JoeManager's" AddressEntry object.
              '
              'As noted above under Command1_Click, you may use either the
              'PropTag or the declared constant. The "table" below shows the
              'PropTag, and the Active Messaging constant. The name each of
              'the underlying MAPI field(s) corresponds to is the same as
              'the constant name less the leading "ActMsg".
              '-------------------------------------------------------------
              '&H64001E ActMsgPR_SENT_REPRESENTING_ADDRTYPE
              '&H65001E ActMsgPR_SENT_REPRESENTING_EMAIL_ADDRESS
              '&H410102 ActMsgPR_SENT_REPRESENTING_ENRTYID
              '&H42001E ActMsgPR_SENT_REPRESENTING_NAME
              '&H3B0102 ActMsgPR_SENT_REPRESENTING_SEARCH_KEY
    
              'As such, the following code is valid in either of
              'the two following formats:
              'objMessage.Fields.Add &H64001E, _
              '  objRecip.AddressEntry.Type
              'objMessage.Fields.Add &H65001E, _
              '  objRecip.AddressEntry.Address
              'objMessage.Fields.Add &H410102, _
              '  objRecip.AddressEntry.ID
              'objMessage.Fields.Add &H42001E, _
              '  objRecip.AddressEntry.Name
              'objMessage.Fields.Add &H3B0102, _
              '  objRecip.AddressEntry.Fields(&H300B0102).Value
              'or
              objMessage.Fields.Add _
                ActMsgPR_SENT_REPRESENTING_ADDRTYPE, _
                objRecip.AddressEntry.Type
              objMessage.Fields.Add _
                ActMsgPR_SENT_REPRESENTING_EMAIL_ADDRESS, _
                objRecip.AddressEntry.Address
              objMessage.Fields.Add _
                ActMsgPR_SENT_REPRESENTING_ENRTYID, _
                objRecip.AddressEntry.ID
              objMessage.Fields.Add _
                ActMsgPR_SENT_REPRESENTING_NAME, _
                objRecip.AddressEntry.Name
              objMessage.Fields.Add _
                ActMsgPR_SENT_REPRESENTING_SEARCH_KEY, _
                objRecip.AddressEntry.Fields(&H300B0102).Value
    
              'Now remove JoeManger from the Recip collection.
              'All we needed was his AddressEntry object.
              objMessage.Recipients.Delete
              Set objRecip = Nothing
    
              'Continue with remaining messaging functionality of your app.
              Set objRecip = objMessage.Recipients.Add
              objRecip.Name = "MyRecip"   'Who you are actually sending to
              objRecip.Type = 1
              objRecip.Resolve
    
              objMessage.Subject = "This is the subject"
              objMessage.Text = "This is the message body."
              objMessage.Send
          End Sub
    
          Private Sub Command3_Click()
              'Cleanup and logoff
              objSession.Logoff
              Unload Me
          End Sub
    
    

REFERENCES

For information on obtaining these libraries, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q171440
   TITLE     : INFO: Where to Acquire the Active Messaging Libraries


For additional information about Collaboration Data Objects versus Active Messaging, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176916
   TITLE     : INFO: Active Messaging and Collaboration Data Objects (CDO)

For additional information on how to use Property Tags to access unexposed properties, plus an extensive listing of available Property Tag constants and values see the Microsoft Developer Network Library (July 1997 or later).


Additional query words: PR_SENT_REPRESENTING

Keywords : ActMsg
Version : WINDOWS:1.1
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.