View Single Post
 
Old 05-18-2015, 02:18 PM
silenttalk silenttalk is offline
Newcomer
 
Join Date: Mar 2004
Posts: 4
Default VB.NET to open contact from received email

Hi

Pulling my hair over this one. very new to VS 2013 but have extensive background with outlook VBS/VBA coding.

We send emails out to a bunch of subscribers for a re booking situation for a membership system. Although we hold the subscribers current email address, they sometimes respond from an alternative (or Alias address) which then fails if we click through to the contact card in Outlook as it is not recognized). I developed a better method using VBS that embedded the Outlook 'Firstname' 'lastname' values in the message that they need to respond to. I then used this to hook a hypertext link to the contact locally such as <outlook:contacts/~fred blogs> which works fine, but some web mail systems i.e. Hotmail strip hyperlink from the reply email (presumably for security reasons). Hotmails Apps under Windows 8 and Outlook work fine though.

So i started developing an addin for out look with a form region on all email messages, simple two buttons on the form, open the contact that replied in the current email message and secondly move the message to a specific folder.

So i want to validate the Contact to open by text that i have embedded in the outbound email that they respond to, lets say 'Renewal Subscription for Fred Bloggs'

What i want the button I click in the form region to do is to parse the email of the current email and open the contact that resonds to 'Renewal Subscription for Fred Bloggs'.

i have code that works for a fixed contact as below but cant work out how to dynamically populate the Fullname variable :-

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objOutlook As Outlook.Application
Dim fullname As String = "Fred Bloggs"
Dim objNS As Outlook.NameSpace
Dim objAddressList As Outlook.MAPIFolder
objOutlook = New Outlook.Application()
objNS = objOutlook.Session
objAddressList = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
'Find the contact by his full name
Dim objItems As Outlook.Items = objAddressList.Items
Dim objContact As Outlook.ContactItem = objItems.Find("[FullName] = '" & fullname & "'") 'ComboBox1.SelectedItem.ToString() & "'")
objContact.Display(True) 'calling this in modal or non modal makes no difference
objContact = Nothing
objItems = Nothing
objAddressList = Nothing
End Sub

Any help would be so gratefully received as i just cant seem to Google my way out of this, and a really nice guy from this forum helped me out 10 years ago 'Robb Dog'

here is hoping again

Matt
Reply With Quote