How to send email using outlook redemption with custom internet headers

Posted on 2008-11-13
Last Modified: 2012-06-27
Hello all,
       I am trying to send a new email using outlook 2003 with custom internet header using, i have done some research and i can't find any way but with using outlook redemption. does anyone have some sample code i can use to do this? i know how to send a normal message without redemption but inserting custom headers is where i am having the issue that and lack of experience with using outlook redemption. anyone know how?
Question by:petersti
    LVL 11

    Accepted Solution

    I have used redemption quite alot to send mails and manipulate other objects.
    The Redemption web site has alot of examples - although you have to work quite hard to find them, and they give you the general idea - not the complete code. The key to understanding the SafeMail item is that you create an Outlook mailitem, and a SafeMail item, and then set SafeMail.item = mailitem. You can now use safemailitem to manipulate your original mail item.
    The fields array gives you access to properties you can't get at with Outlook. You have to jump through some hoops to get the correct tag to address the correct field. Redemption includes functions to find the tags - and the second example shows you how to do that. First it gets the tag. THen it adds (logical OR) more HEX to signify the correct field type associeated with that tag.
    Here is some sample code & notes  from the site which would be a good starting place...The first example shows basic manipulation of fields on a mail. THe second shows retreiving a tag for a custom header - and setting a value. You will need a combination of the two to achieve your goal.
    ....There are dozens more properties that might be of interest to you: PR_TRANSPORT_MESSAGE_HEADERS on e-mail items, PR_SEND_RICH_INFO on Recipient objects, etc. Use MdbView or OutlookSpy to see which properties are available.
    dim sItem, oItem
    set sItem = CreateObject("Redemption.SafeMailItem")
    set oItem = Application.Session.GetDefaultFolder(6).Items(1) 'get first e-mail from the Inbox, can be any other item
    sItem.Item = oItem
    PrSenderEmail = &H0C1F001E
    MsgBox sItem.Fields(PrSenderEmail)
    Another example on how to use the Fields array. The example shows how to add an extra RFC822 header to a message to be sent. It is assumed that MailItem variable points to an existing Outlook MailItem object. When adding your own headers, the name (second argument to getIDsfromNames) can be pretty-much anything you want, but make sure that the GUID is exactly the same as given below - Outlook only adds named properties with that GUID to the outgoing message headers.
    set sItem = CreateObject("Redemption.SafeMailItem")
    sItem.Item = MailItem
    tag = sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "x-test-header")
    tag = tag or &H1E     'the type is PT_STRING8
    sItem.Fields(Tag) = "test value"
    sItem.Subject = sItem.Subject  'to trick Outlook into thinking that something has changed
    To find the original go here: and do a page search on 'headers'
    [You can probably do all this using the RDO element of Redemption which is a replacement for CDO - and hence works an order of magnitude faster than the outlook object model, but you also increase your learning curve by an order of magnitide!]
    LVL 11

    Expert Comment

    so did this work  - what problems did you get?
    If it worked can you assign points - if not let me know what the problem is.

    Author Closing Comment

    sorry for the delay yes it worked thanks.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now