Cannot work out how to set associated contacts in journal using VBSCRIPT

J

Julian Neaum

Greetings
I've just started using vbscript to customise an
application and from a contact item in a set of exchange
public folders I need to call a special email form in the
same set of public folders. I have worked out how to do
this - but I need to record a journal in the same set of
public folders which links the email to the contact
specified in the original contact item. I can get the
journal to work and save in the correct place and I can
get access to the contact in the original item , but I
cannot figure out how to assign the contact to the
journal. I've tried all sorts frolm the various hjelp and
books I have, but the field never seems to set.

Please, what am I doing wrong? THanks in eager
anticipation - current code follows - I know it's not the
best, but I'm just starting out!

' Find the contact ready to assign to the journal
activity to be created for the email item
' Assumes that the current folder and selected
contact is the correct one!!!
' I'll probably be able to be tighter on this later

Set MyCurrentSelection =
Application.ActiveExplorer.Selection
MsgBox "MyCurrentSelectionCount = " &
MyCurrentSelection.Count
Set MyCurrentContact = MyCurrentSelection.Item(1)
'MyCurrentContact.Display
MsgBox "MyCurrentContact = " &
MyCurrentContact.Email1Address
'Set MyCurrentContact = MyCurrentSelection.Item(1)
MsgBox "MyCurrentContact =" &
MyCurrentContact.Email1Address
MsgBox "Item Sent MyCurrentContact = " &
MyCurrentContact.Email1Address
MsgBox "Item Sent MyCurrentContact = " &
MyCurrentContact.FullName

' Set the correct folder for the journal itme ot be
posted.
Set MyNameSpace = Application.GetNameSpace("MAPI")
Set MyRootFolder = MyNameSpace.Folders
("ReceptionDevelopmentFolders")
MsgBox "MyRootFolder = " & MyRootFolder
Set MyJournalFolder = MyRootFolder.Folders
("ReceptionJournal")
MsgBox "MyJOurnalFolder = " & MyJournalFolder
MsgBox "To Address = " & subject & subject


Set MyItem = MyJournalFolder.Items.Add
("IPM.Activity")
MyItem.Subject = subject
MyItem.Type = "E-mail Message"
MsgBox "MyCurrentContact.FullName = " &
MyCurrentContact.FullName
'MyItem.Contacts = MyCurrentContact.FullName
MyItem.ContactNames = "Rubbish;"
MsgBox "MyItem.ContactNames = " &
MyItem.ContactNames

Set MyRecipient = MyItem.Recipients
' MyRecipient.Type = 1
' MsgBox "MyRecipient,Type = " & MyRecipient.Type

' Test value to see if that works!
MyRecipient.Add("Rubbish")

MyItem.Display
 
S

Sue Mosher [MVP-Outlook]

Take a look at the Links collection, which corresponds to the Contacts box
at the bottom of the journal form. The Links.Add method takes a ContactItem
as its argument.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top