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: 26.467  | #26
◀ Previous sample Next sample ▶

Content

ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.

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
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

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, signature and folder for sent items with the help of rules.
email  Send a message