PC Review


Reply
Thread Tools Rate Thread

Linking a contact to a journal entry

 
 
New Member
Join Date: Jun 2012
Posts: 2
 
      6th Jun 2012
Hello,

I am designing a custom form in Outlook 2003 using VBScript. When I open a contact, I want a button that you can click which opens a new journal entry. At the bottom of any journal entry is a text box with a "Contacts" button next to it. I want to automatically populate the text box with the name of the contact so that the journal entry is linked to the contact.

I am successfully doing this with the code below. However I am currently having to loop through all the contacts to find the contact. The user I am writing the code for has hundreds of contacts, so this loop is taking forever. I tried to replace the loop with the code colLinks.Add(Me.FullName) but this did not work because Me.FullName is not the right type of object for the Add function. So is there a way to link a contact to a journal entry without having to use a loop?

Thank you,

Joey


Sub CommandButton2_Click()
Me.Save 'this saves the contact in case it is a new contact
Const olContactItem = 2, olFolderContacts = 10
Set objContact = Application.CreateItem(4)
objContact.Type = "Note"

Set colLinks = objContact.Links
Set objNS = Application.GetNameSpace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderContacts)
Set colContacts = objFolder.Items

'THIS LOOP IS WHAT I WANT TO CHANGE
For Each myContact in colContacts
If Instr(myContact.MessageClass,"IPM.Contact") Then
If myContact.FullName = Me.FullName Then colLinks.Add(myContact)
End If
Next

objContact.Display


End Sub
 
Reply With Quote
 
 
 
 
New Member
Join Date: Jun 2012
Posts: 2
 
      6th Jun 2012
Never mind, I figured it out. I can replace the loop with colLinks.Add(Item)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
journal entries not showing on contact journal page. jeffrey Microsoft Outlook Contacts 3 18th Nov 2008 04:41 PM
How do I add items to the list of Entry Types in a Journal Entry? =?Utf-8?B?ZXhlc3RyYWw=?= Microsoft Outlook Discussion 0 9th Feb 2007 10:26 PM
How to Link a Journal entry to contact in business contact manager =?Utf-8?B?Sk1T?= Microsoft Outlook BCM 3 8th Sep 2005 01:25 PM
Is there a way to change the default entry type in a journal entry =?Utf-8?B?Um95c3RvbiBMb2RnZQ==?= Microsoft Outlook Discussion 0 21st Jan 2005 03:01 PM
Public Contact logged journal entry in a Public Journal folder Mike_B Microsoft Outlook VBA Programming 1 20th Aug 2003 11:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:43 AM.