StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
 
Samples
General
Outlook®
 
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Visitors1716426
Impressions6464579
Links
Imprint
Privacy Policy
Contact
E-Mail: Display infos from the message header
Author: Michael BauerHomepage
Date: 18.07.2009Accessed: 18872
  
Description

This example extracts the return-path property from the message header of an incoming email, and stores the info in the custom property 'ReturnPath'. Then you can display the info in the folder view.

Please copy the code into the modul 'ThisOutlookSession'; also, the Redemption must be installed.

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace
  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderInbox).Folders("test").Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  If TypeOf Item Is Outlook.MailItem Then
    ExtractDataFromMsgHeader Item
  End If
End Sub

Private Sub ExtractDataFromMsgHeader(Mail As Outlook.MailItem)
  On Error Resume Next
  Dim sfItem As Object
  Dim PR_TRANSPORT_MESSAGE_HEADERS&
  Dim MsgHeader$, ReturnPath$
  Dim p1&, p2&
  Dim Prop As Outlook.UserProperty

  PR_TRANSPORT_MESSAGE_HEADERS = &H7D001E
  Set sfItem = CreateObject("redemption.safemailitem")
  sfItem.Item = Mail
  MsgHeader = sfItem.Fields(PR_TRANSPORT_MESSAGE_HEADERS)
  p1 = InStr(1, MsgHeader, "Return-Path:", vbTextCompare)
  If p1 Then
    p1 = p1 + Len("Return-Path:")
    p2 = InStr(p1, MsgHeader, vbCrLf)
    If p2 Then
      ReturnPath = Trim$(Mid$(MsgHeader, p1, p2 - p1))
      Set Prop = Mail.UserProperties("ReturnPath")
      If Prop Is Nothing Then
        Set Prop = Mail.UserProperties.Add("ReturnPath", olText, True)
      End If
      Prop.Value = ReturnPath
      Mail.Save
    End If
  End If
  sfItem.Item = Nothing
  Set sfItem = Nothing
End Sub
 
 

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]

 

Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]

 

SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]

 

OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]