Program to change the TO address

  • Thread starter Thread starter dh
  • Start date Start date
D

dh

I have a combo box with several Email addresses in a Custom Form. When I
select one address from the combo ox, it places it in the Send TO field. My
problem is this, when someone changes their mind and wants to select another
address form the combo box, it adds the address to the TO box, but I want to
clear the other address first.
I need help figuring this one out!
Thanks!
DH
 
Show the code you're using to set the To address.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



I have a combo box with several Email addresses in a Custom Form. When I
select one address from the combo ox, it places it in the Send TO field. My
problem is this, when someone changes their mind and wants to select another
address form the combo box, it adds the address to the TO box, but I want to
clear the other address first.
I need help figuring this one out!
Thanks!
DH
 
Here you go!
Another not, once you select one, the others stop working, so its a work
once solution right now
Thanks Again
DH

Sub Item_CustomPropertyChange(ByVal Name)
MyValue = Name
MyValue = Item.UserProperties("cmbActType").Value

Select Case MyValue
Case "Installation"
If MyValue = "Installation" and Not blnAdminAdded then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
oRecip.type = olTO
blnAdminAdded = True
End if
Case "SO Request"
If MyValue = "Service Order Request" and Not
blnAdminAdded then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
blnAdminAdded = True
End if
Case "Notif"
If MyValue = "Notification Closure" and Not blnAdminAdded
then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
blnAdminAdded = True
End if
End Select
End sub
 
You're using Item.Recipients.Add, which appends, just as the name implies.
If you want to set the To value, use Item.To instead.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Here you go!
Another not, once you select one, the others stop working, so its a work
once solution right now
Thanks Again
DH

Sub Item_CustomPropertyChange(ByVal Name)
MyValue = Name
MyValue = Item.UserProperties("cmbActType").Value

Select Case MyValue
Case "Installation"
If MyValue = "Installation" and Not blnAdminAdded then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
oRecip.type = olTO
blnAdminAdded = True
End if
Case "SO Request"
If MyValue = "Service Order Request" and Not
blnAdminAdded then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
blnAdminAdded = True
End if
Case "Notif"
If MyValue = "Notification Closure" and Not blnAdminAdded
then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
blnAdminAdded = True
End if
End Select
End sub
 
Thanks I will give it a try!
DH
Sue Mosher said:
You're using Item.Recipients.Add, which appends, just as the name implies.
If you want to set the To value, use Item.To instead.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Here you go!
Another not, once you select one, the others stop working, so its a work
once solution right now
Thanks Again
DH

Sub Item_CustomPropertyChange(ByVal Name)
MyValue = Name
MyValue = Item.UserProperties("cmbActType").Value

Select Case MyValue
Case "Installation"
If MyValue = "Installation" and Not blnAdminAdded then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
oRecip.type = olTO
blnAdminAdded = True
End if
Case "SO Request"
If MyValue = "Service Order Request" and Not
blnAdminAdded then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
blnAdminAdded = True
End if
Case "Notif"
If MyValue = "Notification Closure" and Not blnAdminAdded
then
set oRecip = Item.Recipients.Add("(e-mail address removed)")
oRecip.Resolve
blnAdminAdded = True
End if
End Select
End sub

want
 
One more question, will it Clear any other items in the send TO field,
because that is needed.
DH
 
Yes. Setting Item.To replaces any previous values. Why don't you try it and
see for yourself?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



One more question, will it Clear any other items in the send TO field,
because that is needed.
DH
 
Show the code you're using.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



I keep getting a syntax error when I change my code
DH

Sue Mosher said:
Yes. Setting Item.To replaces any previous values. Why don't you try it and
see for yourself?
 
I took this:


and changed the second line
to this:
set oRecip = Item.To("(e-mail address removed)")
didn't like my syntax. I am having trouble finding a good source for
VBscript in outlook syntax book
Any recommends?
DH
Thanks BTW!
 
To is a property. Set its value directly (see
http://www.outlookcode.com/d/propsyntax.htm):

Item.To = "(e-mail address removed)"

For a book, see my signature.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



I took this:


and changed the second line
to this:
set oRecip = Item.To("(e-mail address removed)")
didn't like my syntax. I am having trouble finding a good source for
VBscript in outlook syntax book
Any recommends?
 
That did it, I also got rid of the boolean stuff, don't seem to need it now
Had that in there before because of multible addresses being added..
I already have a copy of your book (was on the list when it came out, the
pages are getting dog eared)
It just would be nice to have it all in one place, specifically about
Oulook, VB script programing.
Thanks again for the great advise!
DH
 
Back
Top