[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1254
  • Last Modified:

How to send email using outlook redemption with custom internet headers

Hello all,
       I am trying to send a new email using outlook 2003 with custom internet header using vb.net, 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?
0
petersti
Asked:
petersti
  • 2
1 Solution
 
DavidT543Commented:
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
sItem.Save
To find the original go here: http://www.dimastr.com/redemption/objects.htm 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!]
0
 
DavidT543Commented:
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.
0
 
peterstiAuthor Commented:
sorry for the delay yes it worked thanks.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now