VBOffice

Get the Receiving Account

This macro tells you by which of your accounts a certain message was received.

Last modified: 2006/05/17 | Accessed: 54.593  | #26
◀ Previous sample Next sample ▶

Content

Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.

For Outlook XP and 2003

Since Outlook XP for every email is stored by which account the email was received if that account was not the default account. By default, Outlook replies using that account. There's two properties, one holds the account name, the other one the account ID and email address.

This sample uses the Redemption to get the information. Select an email, then start the macro, for instance, by pressing ALT+F8.


tip  How to add macros to Outlook
Public Sub ReadNextSendAccount()
  Dim Mail As Redemption.RDOMail
  Dim Session As Redemption.RDOSession
  Dim PR_ACCT_ID As Long
  Dim PR_ACCT_NAME As Long

  Set Session = CreateObject("redemption.rdosession")
  Session.Logon

  With Application.ActiveExplorer.Selection(1)
    Set Mail = Session.GetMessageFromID(.EntryId, .Parent.StoreID)
  End With
  
  PR_ACCT_NAME = Mail.GetIDsFromNames("{00062008-0000-0000-C000-000000000046}", &H8580)
  PR_ACCT_NAME = PR_ACCT_NAME Or &H1E
  
  PR_ACCT_ID = Mail.GetIDsFromNames("{00062008-0000-0000-C000-000000000046}", &H8581)
  PR_ACCT_ID = PR_ACCT_ID Or &H1E
  
  Mail.Fields (PR_ACCT_NAME) & " " & Mail.Fields(PR_ACCT_ID)
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.

Since Outlook 2007

Since Outlook 2007 there's a new property, which holds both the account name and the ID.

Public Sub ReadNextSendAccount()
  Dim Mail As Redemption.RDOMail
  Dim Session As Redemption.RDOSession
  Const PR_NEXT_SEND_ACCT = &HE29001F

  Set Session = CreateObject("redemption.rdosession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT

  With Application.ActiveExplorer.Selection(1)
    Set Mail = Session.GetMessageFromID(.EntryId, .Parent.StoreID)
  End With
  
  MsgBox Mail.Fields(PR_NEXT_SEND_ACCT)
End Sub
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.
email  Send a message