Question

Displaying Cusom headers on outlook 2003

Asked by: Ajay-Singh

Is there any way we can display custom header (for example, X-My-Header) on the outlook and perform sort based on that - similar to Subject, From, Received headers?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-12-23 at 04:09:04ID22102261
Tags

outlook

,

2003

Topic

Outlook Groupware Software

Participating Experts
1
Points
500
Comments
21

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Sorting by Subject column
    There are some subject fields that have "Re:" at the beginning of the line. For example: "Re: Sales Contract" or "Re: Testers". So when you sort by the Subject column, it of course puts all these in the "R" section. Is there a way...
  2. Custom headers
    I am using phpMailer to send out mail via smtp. I am adding a custom header to the email using its addCustomHeader(). How can I access this custom header using the imap function of php in a pop3 mailbox. I know it works because i downloaded the mail sent via phpMailer usin...
  3. Outlook 2000 message headers not printing.
    Hello! I am assisting a customer of mine who uses Outlook 2000. He is complaining of message headers printing in some emails and not printing in other emails. He needs the To:, From:, Subject:, ect lines to print to paper in order to have a complete paper trail. Thanks in...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: BlueDevilFanPosted on 2006-12-23 at 07:04:43ID: 18191911

Greetings, Ajay-Singh.

Are you talking about a header, which appears at the top of a message, or a custom column in a folder view?  If the former, then the answer is a custom message form.  If the latter, then you can create a user-defined field and populate it.  I think there's a "no sort" restriction on user-defined columns, but I'll have to double-check that.

Cheers!

 

by: Ajay-SinghPosted on 2006-12-23 at 07:30:09ID: 18192013

David,

I am looking for latter where i should be able to see the my header "X-My-Header" with From, Subject, Received, Size, Flag etc headers. I tried to create a custom field as Right click on header-> Customize Current View... -> Fields -> New Field. I added this field to the view also, but even though there is a value, it doesn't show up. Is there anything i am doing wrong here?

 

by: BlueDevilFanPosted on 2006-12-26 at 06:53:11ID: 18198177

What is it you want to add to the view?  Have you created and populated a user-property in the messages?  

 

by: Ajay-SinghPosted on 2006-12-26 at 07:20:10ID: 18198289

> Have you created and populated a user-property in the messages?

Yes. The message looks something like:

X-UIDL: 0forum.java.sun.com51190419412414
From: testing
To: me
Reply-To: testing@somehost
Subject: Class Format error
Content-Type: text/html; charset=UTF-8
X-Message-ID: 5119041
X-Total: 0
Date: Tue 26 Dec 2006 12:59:00 +0530
References: 9412414
Followup-To: Java Programming

Body of the message.


I want to see "X-Message-ID" and "X-Total" on the headers.

 

by: BlueDevilFanPosted on 2006-12-26 at 12:16:45ID: 18199505

I'm not clear on how what you posted answers my question.  What you posted looks like part of the message's internet header.  That doesn't have anything to do with my question about creating and populating a user-property in the message.  

 

by: Ajay-SinghPosted on 2006-12-26 at 18:24:18ID: 18200782

actually that was the question - sorry if it was not clear. So, I want to show "X-Message-ID" as new column on the view.

 

by: BlueDevilFanPosted on 2006-12-26 at 18:43:40ID: 18200817

Ok.  "X-Message-ID" isn't an Outlook property.  I believe that getting it will require using CDO (Collaboration Data Objects).  I'll have to double-check that to make sure that piece of information is available via CDO, but I believe it is.  If I'm right, then we'll have to script getting the value via CDO.  That same script will then have to create a user-property in the arriving message item and set its value based on what we get from CDO.  The last step is creating a field in the view to display the user-property.  Will you be the only person using this?  I'm asking because deploying this solution to a large number of users will be cumbersome.

 

by: BlueDevilFanPosted on 2006-12-26 at 19:07:55ID: 18200873

Yes, the internet header is available via CDO.  I went through several messages in my mailbox and none of them have a field called "X-Message-ID" though.  They do have a field called "Message-ID" though.  Also, reading the header is going to trigger Outlook's built-in security.  That means each time the code for doing this fires it's going to cause a dialog-box to pop up warning that an application is accessing your mailbox and asking for your permission to allow it to continue.  There are ways around this, but it generally requires a third-party tool or utility.

 

by: Ajay-SinghPosted on 2006-12-26 at 23:02:53ID: 18201339

Thats good news.
I am not planning to deploy it, its for my personal use.

I have not worked on microsoft technologies much. So, I have few questions:

1. As i understand we can show any custom header by the way you have stated above?
2. Can you please provide me code which would show a header? Don't know what is CDO and how to use it. If there is any third-party tool available, pls post the link.

 

by: BlueDevilFanPosted on 2006-12-27 at 05:57:39ID: 18202159

Good morning, Ajay-Singh.

Here are the answers to your questions.

1.  Yes.
2.  The code for doing this is below along with instructions on how to use it.  CDO (Collaboration Data Objects) is explained in more detail here: http://searchsqlserver.techtarget.com/sDefinition/0,,sid87_gci213570,00.html  The current version of CDO is 1.21.  To see if you have it installed on your computer do a search for CDO.DLL.  There are two third-party products for getting around Outlook's internal security.  The first is called Click-Yes (http://www.contextmagic.com/express-clickyes/).  It is a small utility that sits in the system tray and watches for the security warning dialog-box.  When it sees one it clicks the Yes button for you.  The second is called Outlook Redemption (http://www.dimastr.com/redemption).  It is a COM component (i.e. a DLL) that provides a safe workaround of Outlook security.

Here's the code for displaying a message's internet headers.  This demonstrates how to get the header.  It is not a complete solution to your question.  To become a complete solution we'll have to add code to parse the header and get just the field(s) you want, add a user-defined field to the message, populate it with the value we've parsed out,  and you'll need to decide what to do about the Outlook security issue.  Follow these instructions to use this code.

1.  Start Outlook.
2.  Click Tools->Macro->Visual Basic Editor.
3.  If not already expanded, expand Modules and click on Module1.
4.  Copy the code below and paste it into the right-hand pane of the VB Editor.
5.  Click the diskette icon on the toolbar to save the changes.
6.  Close the VB Editor.
7.  Click Tools->Macro->Security.
8.  Change the Security Level setting to Medium.
9.  Select a message in any folder.
10.  Run the macro (Tools->Macro->Macros, select this macro, click Run).
11.  Outlook's security warning dialog-box will pop up.  Click Yes to allow the macro to run.
12.  A dialog-box will appear either reporting that there was an error retrieving the internet header of the message or displaying that header.

Sub GetInternetHeaders()
    'Set the error handler to allow us to handle errors in code
    On Error Resume Next

    'Declare a constant
    Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E

    'Declare a few variables
    Dim mapSession As Object, _
        olkItem As Outlook.MailItem, _
        mapMessage As Object, _
        mapFields As Object, _
        strHeader As String

    'Create a CDO session and login to it using the existing Outlook session
    Set mapSession = CreateObject("MAPI.Session")
    mapSession.Logon , , False, False, 0

    'Get the selected message's ID
    Set olkItem = Application.ActiveExplorer.Selection(1)
    Set mapMessage = mapSession.GetMessage(olkItem.EntryID, olkItem.Parent.StoreID)

    'Get message fields
    Set mapFields = mapMessage.Fields

    'Get the Internet header
    Err.Clear
    strHeader = mapFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS).Value
    If Err.Number = 0 Then
        MsgBox strHeader
    Else
        MsgBox "Unable to retrieve internet header information.", vbError + vbOKOnly
    End If

    'Logout of the CDO sesison
    mapSession.Logoff

    'Clean up
    Set olkItem = Nothing
    Set mapSession = Nothing
    Set mapMessage = Nothing
    Set mapFields = Nothing
End Sub

 

by: Ajay-SinghPosted on 2006-12-27 at 12:21:11ID: 18204426

Thanks for the descriptive reply.

I am able to run it the way you mentioned.
I don't wan to see the header on the dialog box. I want see on message listing. By default outlook lists the messages and shows "Importance", "Icon", "Attachment", "From", "Subject", "Received", "Size" header on a row for a message. I want to see the value of this header there.

 

by: BlueDevilFanPosted on 2006-12-27 at 12:29:54ID: 18204485

> I want to see the value of this header there
I understand that.  That's why I said, "This demonstrates how to get the header.  It is not a complete solution to your question."  I also said, "you'll need to decide what to do about the Outlook security issue".  It isn't going to be practical to use this unless you decide on how to work around the security issue.  Otherwise, you're going to have a security dialog-box popping up on EVERY message you receive.  Do you want me to go ahead and post the code anyway?

 

by: Ajay-SinghPosted on 2006-12-27 at 12:37:33ID: 18204529

As you suggested i can use the software you have mentioned above - that should solve the security issue. If need we have sign this macro?

Anyway, pls post the code.

 

by: BlueDevilFanPosted on 2006-12-27 at 13:11:16ID: 18204740

Ok, here it is.  Replace what you have now with the code below.  You will need to create a rule that runs this macro for every message you want this to run against.  Set the rule's action to "run a script" and select this script.

Sub GetInternetHeaders(olkItem As Outlook.MailItem)
    'Set the error handler to allow us to handle errors in code
    On Error Resume Next

    'Declare a constant
    Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E

    'Declare a few variables
    Dim mapSession As Object, _
        mapMessage As Object, _
        mapFields As Object, _
        strHeader As String, _
        arrHeaders As Variant, _
        varHeader As Variant

    'Create a CDO session and login to it using the existing Outlook session
    Set mapSession = CreateObject("MAPI.Session")
    mapSession.Logon , , False, False, 0

    'Get the selected message's ID
    Set olkItem = Application.ActiveExplorer.Selection(1)
    Set mapMessage = mapSession.GetMessage(olkItem.EntryID, olkItem.Parent.StoreID)

    'Get message fields
    Set mapFields = mapMessage.Fields

    'Get the Internet header
    Err.Clear
    strHeader = mapFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS).Value
    If Err.Number = 0 Then
        arrHeaders = Split(strHeader, vbCrLf)
        For Each varHeader In arrHeaders
            'Change message-id on the following line to whatever header field you want to use.  If the field name does change, then change 11 to the number of characters in that field's name, plus 1 for the colon.
            If Left(LCase(varHeader), 11) = "message-id:" Then
                'Change MessageID on the following 2 lines to whatever user-property name you want to use
                olkItem.UserProperties.Add "MessageID", olText, True
                olkItem.UserProperties.Item("MessageID") = Trim(Mid(varHeader, 12))
                olkItem.Save
                Exit For
            End If
        Next
    End If

    'Logout of the CDO sesison
    mapSession.Logoff

    'Clean up
    Set olkItem = Nothing
    Set mapSession = Nothing
    Set mapMessage = Nothing
    Set mapFields = Nothing
End Sub

 

by: Ajay-SinghPosted on 2006-12-28 at 06:39:40ID: 18207864

Thanks for chiming this java guy - i am learning VB now. These suggestions were really good. But i don't find it working as expected. When i run this script on rules wizard even though the script is getting called i don't see the new properties. It works correctly if its running on small amount of messages (i tested with 10 message). It fails when the POP server sends large no of messages (tested with 50 messages). I have modified the code little bit[1] to take care of noisy outlook script error dialog.

Is there any way we can see these new user-properties (we have added) when I am reading the mail - it only shows From, To, CC, Subject, Sent.


[1] the modified code:

Sub GetInternetHeaders(olkItem As Outlook.MailItem)
    'Set the error handler to allow us to handle errors in code
    On Error Resume Next

    'Declare a constant
    Const CdoPR_TRANSPORT_MESSAGE_HEADERS = &H7D001E

    'Declare a few variables
    Dim mapSession As Object, _
        mapMessage As Object, _
        mapFields As Object, _
        strHeader As String, _
        arrHeaders As Variant, _
        varHeader As Variant

    Set mapSession = CreateObject("Redemption.RDOSession")
    mapSession.Logon , , False, False, 0

    Set mapMessage = mapSession.GetMessageFromID(olkItem.EntryID, olkItem.Parent.StoreID)
   
    'Get the Internet header
    Err.Clear
    Dim count As Integer
    Dim value As String
    count = 0
    strHeader = mapMessage.Fields(CdoPR_TRANSPORT_MESSAGE_HEADERS)
    On Error GoTo errorHandler
    If Err.Number <> 0 Then
        MsgBox ("Error while reading the fields: " & Err.Description)
    End If

    'MsgBox (strHeader)
    If Err.Number = 0 Then
        arrHeaders = Split(strHeader, vbCrLf)
        For Each varHeader In arrHeaders
            'MsgBox (varHeader)
            ' Change message-id on the following line to whatever header field you want to use.
            ' If the field name does change, then change 11 to the number of characters in that
            ' field's name, plus 1 for the colon.
            If Left(LCase(varHeader), 13) = "x-post-forum:" Then
                'Change MessageID on the following 2 lines to whatever user-property
                'name you want to use
                olkItem.UserProperties.Add "Forum", olText, True
                value = Trim(Mid(varHeader, 14))
                olkItem.UserProperties.Item("Forum") = value
                count = count + 1
                'MsgBox ("Adding Forum " & value)
            ElseIf Left(LCase(varHeader), 12) = "x-post-type:" Then
                olkItem.UserProperties.Add "Type", olText, True
                value = Trim(Mid(varHeader, 13))
                olkItem.UserProperties.Item("Type") = value
                count = count + 1
            End If
           
            If count >= 2 Then
                Exit For
            End If
        Next
    End If
    olkItem.Save

errorHandler:
    If Err.Number <> 0 Then
        MsgBox ("Genera Error, code = " & Err.Number & ", Description = " & Err.Description)
    End If

    'Logout of the CDO sesison
    mapSession.Logoff
    'Clean up
    'Set olkItem = Nothing
    Set mapSession = Nothing
    Set mapMessage = Nothing
    Set mapFields = Nothing
End Sub

 

by: Ajay-SinghPosted on 2006-12-28 at 06:55:53ID: 18207960

Another thing to add - my rule is moving the mail from one personal folder to another.

 

by: BlueDevilFanPosted on 2006-12-28 at 09:27:49ID: 18209176

> When i run this script on rules wizard even though the script is getting called i don't see the new properties.

Have you modified your view and added the new properties to it?


> It works correctly if its running on small amount of messages (i tested with 10 message). It fails when the POP server sends large no of messages (tested with 50 messages).

I'm a little confused.  In the last comment you say it's not working and in this one you say it works perfectly but only if the number of received messages is small.  If it's working at all, even for a few messages, then I don't understand your prior comment.  Please help me understand.  The process should work no matter how many messages are received.  If it doesn't, then it's not the script but some internal Outlook issue that restricts rule processing when more than a set number of items are received.


> Is there any way we can see these new user-properties (we have added) when I am reading the mail

You should be able to do it with a custom form.  In addition to building a custom form you'd also have to add to the code to change the form type of arriving messages to your custom form.

> Another thing to add - my rule is moving the mail from one personal folder to another.
Sorry, I don't understand what that has to do with this issue.  Unless you're saying that moving the messages to another folder is somehow causing a problem.

 

by: Ajay-SinghPosted on 2006-12-28 at 09:43:57ID: 18209274

> Have you modified your view and added the new properties to it?
Yes.

> I'm a little confused.  In the last comment you say it's not working and in this one you say it works perfectly...

Here is the situation... I have created a rule on my outlook saying that any mail coming from a particular mail account, move it to some folder (this folder resides on different pst) and run the script. Now, when the outlook checks for new mail from my POP server and lets say it downloads 1 mail - the mail is being moved to the folder but i could not see the properties. I added some debug statements to popup on some places to make sure that its adding the properties. I could see the popups coming.

I did further experiment - when the folder i am trying to move resides on the same personal folder, it works correctly (but only for small amount of mails, ie when pop server sends 5-10 mails - it works. when it sends 100 mails it doesn't). Quite wiered!

 

by: BlueDevilFanPosted on 2006-12-28 at 09:53:50ID: 18209329

> the mail is being moved to the folder but i could not see the properties
Probably because the destination folder doesn't have the properties added to it.  Can the rule be adjusted to move the item before the script is run?

> when pop server sends 5-10 mails - it works. when it sends 100 mails it doesn't)
How long have you waited?  When Outlook gets a large number of messages rule processing is deferred until Outlook decides that the computer is idle.  It can take a minute or two sometimes.

 

by: Ajay-SinghPosted on 2006-12-28 at 11:19:46ID: 18209843

> Can the rule be adjusted to move the item before the script is run?
Its already doing. It first moves and then run the script.

> Probably because the destination folder doesn't have the properties added to it.
What should i do to add these properties? The way i did was: I created a view containing the new properties and when the message is moved i applied that view.

> How long have you waited?
Couple of minutes. Its happening with 50 no of messages (the messages are not of big fixes, max 8K, avg 2K) - not sure if outlook is deferring for it.

 

by: Ajay-SinghPosted on 2006-12-29 at 10:13:03ID: 18215475

I somehow managed to fix it.

Thanks for you help.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...