Changing recipient with options buttons

M

Matt

I have been building a form in outlook and had hoped to avoid using any code
but am now left with no option.

I wish to change the recipient value based on the seletion of an option
button. I can not use the automatically update field property as when the
address resolves with our exchange address book outlook changes it back again.

The problem I am facing is that I can not remove the address from the to
field if the user subsequently changes the option.

Can anyone help. Thanks.
 
S

Sue Mosher [MVP-Outlook]

What in particular are you looking for help with? How to remove a recipient (Recipients.Remove or Recipient.Delete)?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

Matt

I am new to VB Script and am finding the scripting tools and lack of any
debugging very difficult. I need to add code to each of the 4 option buttons
I have with a different known string for each.

My code needs to:

1. Run code on clicking the option button. If I can't do this then detect a
change in the field that they are all tied to.

2. Remove all "to" recipients of the current message in order to ensure it
is not send to more than one of the routed recipients. Certain "Bcc" and "cc"
addresses are set as default on the form and should not be changed.

3. Add [knownstring] "to" recipients to the current message

4. End Code

Unfortunately my company firewall will not let me download the code samples
from your website.

My current stab below does not appear to do anything:

Sub OptionButton1_Click()
Recipients.Add "(e-mail address removed)"
End Sub


Any help you can give me would be gratefull appreciated. We have ordered
your book but don't have time to wait for amazon.

Thanks

Matt
 
S

Sue Mosher [MVP-Outlook]

1) Details depend on whether the option buttons are bound to an Outlook property.
Sub OptionButton1_Click()

Only works if OptionButton1 is unbound. If they're bound to an Outlook property, then you must use the Item_PropertyChange or Item)CustomPropertyChange event handler.

2) Item.To = ""

3) Item.To = "(e-mail address removed);[email protected]"

Where does [knownstring] come from?
Recipients.Add "(e-mail address removed)"

Should be Item.Recipients.Add

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Matt said:
I am new to VB Script and am finding the scripting tools and lack of any
debugging very difficult. I need to add code to each of the 4 option buttons
I have with a different known string for each.

My code needs to:

1. Run code on clicking the option button. If I can't do this then detect a
change in the field that they are all tied to.

2. Remove all "to" recipients of the current message in order to ensure it
is not send to more than one of the routed recipients. Certain "Bcc" and "cc"
addresses are set as default on the form and should not be changed.

3. Add [knownstring] "to" recipients to the current message

4. End Code

Unfortunately my company firewall will not let me download the code samples
from your website.

My current stab below does not appear to do anything:

Sub OptionButton1_Click()
Recipients.Add "(e-mail address removed)"
End Sub
 
M

Matt

Sue,

Many thanks for steering me in the right direction. I have posted the code
that worked for me for others to benefit from:

Sub Item_CustomPropertyChange(ByVal myPropName)
Select Case myPropName
Case "transitory"
strTransitoryValue = Item.UserProperties("transitory")
Select Case strTransitoryValue
Case "NewToPremier"
Item.to= ""
Item.to = "(e-mail address removed)"
Case "ExistingPremier"
Item.to= ""
Item.to = "(e-mail address removed)"
Case "IIM"
Item.to= ""
Item.to = "(e-mail address removed)"
Case "Outbound"
Item.to= ""
Item.to = "(e-mail address removed)"
Case Else
End Select
Case Else
End Select
End Sub

My real issue appeared to be around inconcistantly using a capital "t" for
the field/property name. I guess that's just VBA's autocorrect making me lazy.

Thanks again.

Matt

Sue Mosher said:
1) Details depend on whether the option buttons are bound to an Outlook property.
Sub OptionButton1_Click()

Only works if OptionButton1 is unbound. If they're bound to an Outlook property, then you must use the Item_PropertyChange or Item)CustomPropertyChange event handler.

2) Item.To = ""

3) Item.To = "(e-mail address removed);[email protected]"

Where does [knownstring] come from?
Recipients.Add "(e-mail address removed)"

Should be Item.Recipients.Add

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Matt said:
I am new to VB Script and am finding the scripting tools and lack of any
debugging very difficult. I need to add code to each of the 4 option buttons
I have with a different known string for each.

My code needs to:

1. Run code on clicking the option button. If I can't do this then detect a
change in the field that they are all tied to.

2. Remove all "to" recipients of the current message in order to ensure it
is not send to more than one of the routed recipients. Certain "Bcc" and "cc"
addresses are set as default on the form and should not be changed.

3. Add [knownstring] "to" recipients to the current message

4. End Code

Unfortunately my company firewall will not let me download the code samples
from your website.

My current stab below does not appear to do anything:

Sub OptionButton1_Click()
Recipients.Add "(e-mail address removed)"
End Sub
 

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