Load a recipient based on a value in a combo box

Status
Not open for further replies.
Q

Q2x1ZWxlc3M

I have a custom Outlook 2007 form that I need help with writing code to

perform the following.

I have two Drop Down boxes: Box 1. person - responsibility Box 2. location

- person

When a certain person is selected in the 1st. Box I want the person's name

to automatically load as a recipient of the email. I would also like to be

able to add an additional name as a recipients to the same email when Box 2.

Has a location and person selected. I use the following code to fill in a

recipient based on a click event but I am not sure how to do an event based

on the value in a drop down box

Sub CommandButton2_Click()

Recipients.Add "Doe, John"

Recipients.ResolveAll

Recipients.Add "Smith, Bill"

Recipients.ResolveAll

End Sub

Thanks In advance
 
The event to use depends on whether the control is bound to an Outlook

property. See http://www.outlookcode.com/article.aspx?ID=38

Sue Mosher

"Clueless" <Clueless> wrote in message

news:BFA946AF-B1F5-4504-AE87-5782C76780D0@microsoft.com...
> I have a custom Outlook 2007 form that I need help with writing code to
> perform the following.

> I have two Drop Down boxes: Box 1. person - responsibility Box 2.
> location
> - person

> When a certain person is selected in the 1st. Box I want the person's name
> to automatically load as a recipient of the email. I would also like to be
> able to add an additional name as a recipients to the same email when Box
> 2.
> Has a location and person selected. I use the following code to fill in a
> recipient based on a click event but I am not sure how to do an event
> based
> on the value in a drop down box

> Sub CommandButton2_Click()
> Recipients.Add "Doe, John"
> Recipients.ResolveAll
> Recipients.Add "Smith, Bill"
> Recipients.ResolveAll
> End Sub

> Thanks In advance

>
 
Sue,

The control is bound, I used the Item PropertyChange (ByVal name)

The following code would put John Doe has the recipent but it kept doing it

multiple times until outlook locked up. I want the recipient to be add just

once or removed and changed based on the My.Control.Value. in my Combo Box.

Sub Item_PropertyChange(ByVal Name)

Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")

Set MyControl = MyPage.Controls("ComboBox24")

If Right(MyControl.Value,1) = "e" Then

Set Recipient = Recipients.Add ("Doe, John")

Recipient.Type = 1

Recipients.ResolveAll

End If

End Sub

What am I missing?

Thanks

"Sue Mosher [MVP]" wrote:


> The event to use depends on whether the control is bound to an Outlook
> property. See http://www.outlookcode.com/article.aspx?ID=38

> > Sue Mosher
> > >

> "Clueless" <Clueless> wrote in message
> news:BFA946AF-B1F5-4504-AE87-5782C76780D0@microsoft.com...
> >I have a custom Outlook 2007 form that I need help with writing code to
> > perform the following.
> > I have two Drop Down boxes: Box 1. person - responsibility Box 2.
> > location
> > - person
> > When a certain person is selected in the 1st. Box I want the person's name
> > to automatically load as a recipient of the email. I would also like to be
> > able to add an additional name as a recipients to the same email when Box
> > 2.
> > Has a location and person selected. I use the following code to fill in a
> > recipient based on a click event but I am not sure how to do an event
> > based
> > on the value in a drop down box
> > Sub CommandButton2_Click()
> > Recipients.Add "Doe, John"
> > Recipients.ResolveAll
> > Recipients.Add "Smith, Bill"
> > Recipients.ResolveAll
> > End Sub
> > Thanks In advance
> >


>
 
Please look again at the sample code on the page I suggested. It shows how

to run code only on a change to the property you're interested in, not all

properties.

Also, if the control is bound, your code should work with the property

value, not the control value. And I suspect it's bound to a custom property,

not a standard property, which means you need to use the

CustomPropertyChange event.

Sue Mosher

"Clueless" <Clueless> wrote in message

news:D57432AB-13C9-4BD3-B70F-BEEEF1C0C81E@microsoft.com...
> Sue,

> The control is bound, I used the Item PropertyChange (ByVal name)

> The following code would put John Doe has the recipent but it kept doing
> it
> multiple times until outlook locked up. I want the recipient to be add
> just
> once or removed and changed based on the My.Control.Value. in my Combo
> Box.

> Sub Item_PropertyChange(ByVal Name)
> Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")
> Set MyControl = MyPage.Controls("ComboBox24")
> If Right(MyControl.Value,1) = "e" Then
> Set Recipient = Recipients.Add ("Doe, John")
> Recipient.Type = 1
> Recipients.ResolveAll
> End If

> End Sub

> What am I missing?

> Thanks

> "Sue Mosher [MVP]" wrote:
>
> > The event to use depends on whether the control is bound to an Outlook
> > property. See http://www.outlookcode.com/article.aspx?ID=38
>

>> "Clueless" <Clueless> wrote in message
> > news:BFA946AF-B1F5-4504-AE87-5782C76780D0@microsoft.com...
> > >I have a custom Outlook 2007 form that I need help with writing code to
> > > perform the following.
> >> > I have two Drop Down boxes: Box 1. person - responsibility Box 2.
> > > location
> > > - person
> >> > When a certain person is selected in the 1st. Box I want the person's
> > > name
> > > to automatically load as a recipient of the email. I would also like to
> > > be
> > > able to add an additional name as a recipients to the same email when
> > > Box
> > > 2.
> > > Has a location and person selected. I use the following code to fill in
> > > a
> > > recipient based on a click event but I am not sure how to do an event
> > > based
> > > on the value in a drop down box
> >> > Sub CommandButton2_Click()
> > > Recipients.Add "Doe, John"
> > > Recipients.ResolveAll
> > > Recipients.Add "Smith, Bill"
> > > Recipients.ResolveAll
> > > End Sub
 
Sue,

You were correct I was not understanding the code correctly but I do have it

working from your instructions. However, I am trying to use the change

property values event but want it to also to occur based on a check box

click even. for example.

If the check box is true when the change property values occurs nothing

happens but once the checkbox is clicked the change properties value then is

initiated. I can't seem to nest the events. What I have below only occurs

after the box is clicked and then I go back and select the drop down box

again. Thanks in advance

ub Item_CustomPropertyChange(ByVal Name)

Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")

Set MyControl = MyPage.Controls("CheckBox14")

If MyControl.Value = True then

Select Case Name

Case "Vendor"

strMyProp1 = Item.UserProperties("Vendor")

Select Case Right(strMyProp1,1)

Case "n"

Set Recipient = Recipients.Add ("Doe, John")

Recipient.Type = 1

Recipients.ResolveAll

End Select

Select Case Right(strMyProp1,1)

Case "g"

Set Recipient = Recipients.Add ("Wilson, greg")

Recipient.Type = 1

Recipients.ResolveAll

End Select

Select Case Right(strMyProp1,1)

Case "r"

Set Recipient = Recipients.Add ("Ross, Mike")

Recipient.Type = 1

Recipients.ResolveAll

End Select

End Select

End If

End Sub

"Sue Mosher [MVP]" wrote:


> Please look again at the sample code on the page I suggested. It shows how
> to run code only on a change to the property you're interested in, not all
> properties.

> Also, if the control is bound, your code should work with the property
> value, not the control value. And I suspect it's bound to a custom property,
> not a standard property, which means you need to use the
> CustomPropertyChange event.

> > Sue Mosher
> > >

> "Clueless" <Clueless> wrote in message
> news:D57432AB-13C9-4BD3-B70F-BEEEF1C0C81E@microsoft.com...
> > Sue,
> > The control is bound, I used the Item PropertyChange (ByVal name)
> > The following code would put John Doe has the recipent but it kept doing
> > it
> > multiple times until outlook locked up. I want the recipient to be add
> > just
> > once or removed and changed based on the My.Control.Value. in my Combo
> > Box.
> > Sub Item_PropertyChange(ByVal Name)
> > Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")
> > Set MyControl = MyPage.Controls("ComboBox24")
> > If Right(MyControl.Value,1) = "e" Then
> > Set Recipient = Recipients.Add ("Doe, John")
> > Recipient.Type = 1
> > Recipients.ResolveAll
> > End If
> > End Sub
> > What am I missing?
> > Thanks
> > "Sue Mosher [MVP]" wrote:
> >
> >> The event to use depends on whether the control is bound to an Outlook
> >> property. See http://www.outlookcode.com/article.aspx?ID=38
> >
> >> "Clueless" <Clueless> wrote in message
> >> news:BFA946AF-B1F5-4504-AE87-5782C76780D0@microsoft.com...
> >> >I have a custom Outlook 2007 form that I need help with writing code to
> >> > perform the following.
> >> >> > I have two Drop Down boxes: Box 1. person - responsibility Box 2.
> >> > location
> >> > - person
> >> >> > When a certain person is selected in the 1st. Box I want the person's
> >> > name
> >> > to automatically load as a recipient of the email. I would also like to
> >> > be
> >> > able to add an additional name as a recipients to the same email when
> >> > Box
> >> > 2.
> >> > Has a location and person selected. I use the following code to fill in
> >> > a
> >> > recipient based on a click event but I am not sure how to do an event
> >> > based
> >> > on the value in a drop down box
> >> >> > Sub CommandButton2_Click()
> >> > Recipients.Add "Doe, John"
> >> > Recipients.ResolveAll
> >> > Recipients.Add "Smith, Bill"
> >> > Recipients.ResolveAll
> >> > End Sub


>
 
Is the check box bound or unbound? If bound, to what property? Is Vendor the

name of the property bound to the combo box with the list of names in it?

Sue Mosher

"Clueless" <Clueless> wrote in message

news:510A1947-6CD8-49A7-8762-3760A0C708FB@microsoft.com...
> Sue,

> You were correct I was not understanding the code correctly but I do have
> it
> working from your instructions. However, I am trying to use the change
> property values event but want it to also to occur based on a check box
> click even. for example.

> If the check box is true when the change property values occurs nothing
> happens but once the checkbox is clicked the change properties value then
> is
> initiated. I can't seem to nest the events. What I have below only occurs
> after the box is clicked and then I go back and select the drop down box
> again. Thanks in advance

> ub Item_CustomPropertyChange(ByVal Name)
> Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")
> Set MyControl = MyPage.Controls("CheckBox14")
> If MyControl.Value = True then
> Select Case Name
> Case "Vendor"
> strMyProp1 = Item.UserProperties("Vendor")
> Select Case Right(strMyProp1,1)
> Case "n"
> Set Recipient = Recipients.Add ("Doe, John")
> Recipient.Type = 1
> Recipients.ResolveAll

> End Select
> Select Case Right(strMyProp1,1)
> Case "g"
> Set Recipient = Recipients.Add ("Wilson, greg")
> Recipient.Type = 1
> Recipients.ResolveAll
> End Select

> Select Case Right(strMyProp1,1)
> Case "r"
> Set Recipient = Recipients.Add ("Ross, Mike")
> Recipient.Type = 1
> Recipients.ResolveAll
> End Select

> End Select

> End If
> End Sub

> "Sue Mosher [MVP]" wrote:
>
> > Please look again at the sample code on the page I suggested. It shows
> > how
> > to run code only on a change to the property you're interested in, not
> > all
> > properties.
>

>> Also, if the control is bound, your code should work with the property
> > value, not the control value. And I suspect it's bound to a custom
> > property,
> > not a standard property, which means you need to use the
> > CustomPropertyChange event.



>

>> "Clueless" <Clueless> wrote in message
> > news:D57432AB-13C9-4BD3-B70F-BEEEF1C0C81E@microsoft.com...
> > > Sue,
> >> > The control is bound, I used the Item PropertyChange (ByVal name)
> >> > The following code would put John Doe has the recipent but it kept
> > > doing
> > > it
> > > multiple times until outlook locked up. I want the recipient to be add
> > > just
> > > once or removed and changed based on the My.Control.Value. in my Combo
> > > Box.
> >> > Sub Item_PropertyChange(ByVal Name)
> > > Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")
> > > Set MyControl = MyPage.Controls("ComboBox24")
> > > If Right(MyControl.Value,1) = "e" Then
> > > Set Recipient = Recipients.Add ("Doe, John")
> > > Recipient.Type = 1
> > > Recipients.ResolveAll
> > > End If
> >> > End Sub
> >> > What am I missing?
> >> > Thanks
> >>> > "Sue Mosher [MVP]" wrote:
> >> >> The event to use depends on whether the control is bound to an Outlook
> > >> property. See http://www.outlookcode.com/article.aspx?ID=38
> > >
>> >> "Clueless" <Clueless> wrote in message
> > >> news:BFA946AF-B1F5-4504-AE87-5782C76780D0@microsoft.com...
> > >> >I have a custom Outlook 2007 form that I need help with writing code
> > >> >to
> > >> > perform the following.
> > >>> >> > I have two Drop Down boxes: Box 1. person - responsibility Box 2.
> > >> > location
> > >> > - person
> > >>> >> > When a certain person is selected in the 1st. Box I want the
> > >> > person's
> > >> > name
> > >> > to automatically load as a recipient of the email. I would also like
> > >> > to
> > >> > be
> > >> > able to add an additional name as a recipients to the same email
> > >> > when
> > >> > Box
> > >> > 2.
> > >> > Has a location and person selected. I use the following code to fill
> > >> > in
> > >> > a
> > >> > recipient based on a click event but I am not sure how to do an
> > >> > event
> > >> > based
> > >> > on the value in a drop down box
> > >>> >> > Sub CommandButton2_Click()
> > >> > Recipients.Add "Doe, John"
> > >> > Recipients.ResolveAll
> > >> > Recipients.Add "Smith, Bill"
> > >> > Recipients.ResolveAll
> > >> > End Sub

>

>
>>
 
Sue,

I was able to figure it out based on your examples in your link.

My new issues is that I have created a custom form with check boxes that

display names in the recipient field when selected. When I run the form all

the code works as I need, but if some one receives the form and forwards to

someone else the code will not longer activate. I did not have this issue

with Outlook 2003, but when I went to 2007 and recreated my form I could nt

get it to work like Outlook 2003.

Outlook 2003 tool bar allowed anyone to access the form in the

organizational library then edit the form before sending. The receiver of the

outlook 2003 for coudl then go to tool bars, forms, run this form then send

it to the next person for review. How can I get this to work in outlook 2007,

it does not seem to give the same option as 2003. Please help or gving me

some reading to understadn what I need to do.

Thanks for all your help

"Sue Mosher [MVP]" wrote:


> Is the check box bound or unbound? If bound, to what property? Is Vendor the
> name of the property bound to the combo box with the list of names in it?

> > Sue Mosher
> > >

> "Clueless" <Clueless> wrote in message
> news:510A1947-6CD8-49A7-8762-3760A0C708FB@microsoft.com...
> > Sue,
> > You were correct I was not understanding the code correctly but I do have
> > it
> > working from your instructions. However, I am trying to use the change
> > property values event but want it to also to occur based on a check box
> > click even. for example.
> > If the check box is true when the change property values occurs nothing
> > happens but once the checkbox is clicked the change properties value then
> > is
> > initiated. I can't seem to nest the events. What I have below only occurs
> > after the box is clicked and then I go back and select the drop down box
> > again. Thanks in advance
> > ub Item_CustomPropertyChange(ByVal Name)
> > Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")
> > Set MyControl = MyPage.Controls("CheckBox14")
> > If MyControl.Value = True then
> > Select Case Name
> > Case "Vendor"
> > strMyProp1 = Item.UserProperties("Vendor")
> > Select Case Right(strMyProp1,1)
> > Case "n"
> > Set Recipient = Recipients.Add ("Doe, John")
> > Recipient.Type = 1
> > Recipients.ResolveAll
> > End Select
> > Select Case Right(strMyProp1,1)
> > Case "g"
> > Set Recipient = Recipients.Add ("Wilson, greg")
> > Recipient.Type = 1
> > Recipients.ResolveAll
> > End Select
> > Select Case Right(strMyProp1,1)
> > Case "r"
> > Set Recipient = Recipients.Add ("Ross, Mike")
> > Recipient.Type = 1
> > Recipients.ResolveAll
> > End Select
> > End Select
> > End If
> > End Sub
> > "Sue Mosher [MVP]" wrote:
> >
> >> Please look again at the sample code on the page I suggested. It shows
> >> how
> >> to run code only on a change to the property you're interested in, not
> >> all
> >> properties.
> >
> >> Also, if the control is bound, your code should work with the property
> >> value, not the control value. And I suspect it's bound to a custom
> >> property,
> >> not a standard property, which means you need to use the
> >> CustomPropertyChange event.

>
> >
> >> "Clueless" <Clueless> wrote in message
> >> news:D57432AB-13C9-4BD3-B70F-BEEEF1C0C81E@microsoft.com...
> >> > Sue,
> >> >> > The control is bound, I used the Item PropertyChange (ByVal name)
> >> >> > The following code would put John Doe has the recipent but it kept
> >> > doing
> >> > it
> >> > multiple times until outlook locked up. I want the recipient to be add
> >> > just
> >> > once or removed and changed based on the My.Control.Value. in my Combo
> >> > Box.
> >> >> > Sub Item_PropertyChange(ByVal Name)
> >> > Set MyPage = Item.GetInspector.ModifiedFormPages("Requisition Form")
> >> > Set MyControl = MyPage.Controls("ComboBox24")
> >> > If Right(MyControl.Value,1) = "e" Then
> >> > Set Recipient = Recipients.Add ("Doe, John")
> >> > Recipient.Type = 1
> >> > Recipients.ResolveAll
> >> > End If
> >> >> > End Sub
> >> >> > What am I missing?
> >> >> > Thanks
> >> >> >> > "Sue Mosher [MVP]" wrote:
> >> >> >> The event to use depends on whether the control is bound to an Outlook
> >> >> property. See http://www.outlookcode.com/article.aspx?ID=38
> >> >
> >> >> "Clueless" <Clueless> wrote in message
> >> >> news:BFA946AF-B1F5-4504-AE87-5782C76780D0@microsoft.com...
> >> >> >I have a custom Outlook 2007 form that I need help with writing code
> >> >> >to
> >> >> > perform the following.
> >> >> >> >> > I have two Drop Down boxes: Box 1. person - responsibility Box 2.
> >> >> > location
> >> >> > - person
> >> >> >> >> > When a certain person is selected in the 1st. Box I want the
> >> >> > person's
> >> >> > name
> >> >> > to automatically load as a recipient of the email. I would also like
> >> >> > to
> >> >> > be
> >> >> > able to add an additional name as a recipients to the same email
> >> >> > when
> >> >> > Box
> >> >> > 2.
> >> >> > Has a location and person selected. I use the following code to fill
> >> >> > in
> >> >> > a
> >> >> > recipient based on a click event but I am not sure how to do an
> >> >> > event
> >> >> > based
> >> >> > on the value in a drop down box
> >> >> >> >> > Sub CommandButton2_Click()
> >> >> > Recipients.Add "Doe, John"
> >> >> > Recipients.ResolveAll
> >> >> > Recipients.Add "Smith, Bill"
> >> >> > Recipients.ResolveAll
> >> >> > End Sub
> >
> >
> >>


>
 
It sounds like your form is not properly published to the Organizational

Forms library with the "send form definition with item" box unchecked. Only

properly published forms can run code. See

http://www.outlookcode.com/article.aspx?id=61?

Also, the Forward action on the form design's Actions page needs to point to

the published form.

Sue Mosher

"Clueless" <Clueless> wrote in message

news:4B07516E-0031-4404-891C-AD5F80B10427@microsoft.com...

> My new issues is that I have created a custom form with check boxes that
> display names in the recipient field when selected. When I run the form
> all
> the code works as I need, but if some one receives the form and forwards
> to
> someone else the code will not longer activate. I did not have this issue
> with Outlook 2003, but when I went to 2007 and recreated my form I could
> nt
> get it to work like Outlook 2003.

> Outlook 2003 tool bar allowed anyone to access the form in the
> organizational library then edit the form before sending. The receiver of
> the
> outlook 2003 for coudl then go to tool bars, forms, run this form then
> send
> it to the next person for review. How can I get this to work in outlook
> 2007,
> it does not seem to give the same option as 2003. Please help or gving me
> some reading to understadn what I need to do.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Outlook 2016 Unable to load Outlook data pst file Using Outlook 5
J VB6 Add-in fails to load in Outlook 16 - message useless Outlook VBA and Custom Forms 4
A How can I load a HTML template into the WordEditor? Outlook VBA and Custom Forms 3
Diane Poremsky Always Load an Outlook Addin Using Outlook 1
William getting custom form to load category colors Outlook VBA and Custom Forms 4
J BCM 2013 in Outlook 2013 will not load BCM (Business Contact Manager) 5
H Macro to load an Outlook Template Using Outlook 2
M Load a template when you reply Using Outlook 1
A Not able to load an add-in for outlook 2007 developed in VSTO 2005 Outlook VBA and Custom Forms 2
S COM Addin Failed to load in Outlook 2003 Outlook VBA and Custom Forms 1
S Outlook 2007 Add-in strange load behavior Outlook VBA and Custom Forms 10
G "Cannot load GUI library into memory" Outlook VBA and Custom Forms 3
D Why does BCM not always load when I restart Outlook? BCM (Business Contact Manager) 1
G Using VBA to load the CC line on an Outlook email Outlook VBA and Custom Forms 2
S BCM does not load in Windows 7 BCM (Business Contact Manager) 1
P Can you load an OlkComboBox and show a previously selected value? Outlook VBA and Custom Forms 1
W My VSTO 3.0 Outlook addin doesn’t load Outlook VBA and Custom Forms 1
P What is it, and why won't it load? BCM (Business Contact Manager) 10
M VBA Form how to load in Outlook 2003 Outlook VBA and Custom Forms 4
S Business Data Import and Export Load Error Cannot Map BCM (Business Contact Manager) 1
D Outlook AddIn can't load outside Visual Studio Outlook VBA and Custom Forms 1
D Application.ActiveInspector() is Null on Ribbon Load Outlook VBA and Custom Forms 1
S Business contact manager will not load? databinding? BCM (Business Contact Manager) 2
J add-in won't load Outlook VBA and Custom Forms 12
N Load audio file into Media Player control Outlook VBA and Custom Forms 2
F Graphics in email / Mac recipient garbled Using Outlook 0
T Outlook 2010 recipient no longer shows in 'Send To' Using Outlook 0
S Adding a recipient's column to Sent folder in Outlook 2010 Outlook VBA and Custom Forms 1
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
C Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 4
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
K Use VBA to find Sender and Recipient from Microsfot 365 Journaled Email Items Outlook VBA and Custom Forms 3
B VBScript doesn't run on Recipient Email Outlook VBA and Custom Forms 2
T "Words In Recipient's Address" Rule Causes Outlook To Stop Processing Rules Using Outlook 3
M ERROR: None of your email accounts could send to this recipient Using Outlook 2
N Custom Form Controls Not Visible To Recipient Outlook VBA and Custom Forms 3
Daniel Schunk User-defined form arrives empty at the recipient Using Outlook 3
B Looking to get the Recipient email address (or even the "friendly name") from an email I am replying to using VBA Outlook VBA and Custom Forms 4
D Moving Emails Based on Recipient/Sender Outlook VBA and Custom Forms 4
J Signatures that contain recipient's email address Outlook VBA and Custom Forms 7
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
L Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 33
M recipient cache? Using Outlook 2
N Importing Google contacts from CSV file removes recipient names in autocomplete list Using Outlook 0
H How to show recipient email address? Using Outlook 0
R OL2010 - Send to Mail Recipient going to wrong account Using Outlook 1
J Searh For Recipient Email address Outlook VBA and Custom Forms 1
A Extracting only one recipient from Msgitem.To Outlook VBA and Custom Forms 7
Diane Poremsky Display the Recipient Email Address in the Sent Items Folder Using Outlook 0
E Meeting reminders are set for the recipient Exchange Server Administration 9

Similar threads

Back
Top