Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook - Using Forms (http://www.outlookbanter.com/outlook-using-forms/)
-   -   How to Access the "To" Recipient field and update it in outlook form (http://www.outlookbanter.com/outlook-using-forms/80070-how-access-recipient-field-update.html)

Venkat M October 10th 08 09:06 PM

How to Access the "To" Recipient field and update it in outlook form
 

Hi,
I am having problem with vb script in outlook form.....
I want to access the To Recipient field in the outlook form inorder to
change the recipient email everytime whenever a particular box is
checked...I hope someone would help me by providing the command vb code
for this?

Thanks in advance,
Venkat


*** Sent via Developersdex http://www.developersdex.com ***

Sue Mosher [MVP-Outlook] October 10th 08 11:07 PM

How to Access the "To" Recipient field and update it in outlook fo
 
More details please: Are you trying to replace any existing recipients? Add a
recipient? Is the check box bound to an Outlook property?

In the meantime, you might find the article at
http://www.outlookcode.com/article.aspx?ID=38 useful as an overview of event
and property syntax.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54




"Venkat M" wrote:


Hi,
I am having problem with vb script in outlook form.....
I want to access the To Recipient field in the outlook form inorder to
change the recipient email everytime whenever a particular box is
checked...I hope someone would help me by providing the command vb code
for this?

Thanks in advance,
Venkat


*** Sent via Developersdex http://www.developersdex.com ***


Venkat M October 11th 08 02:28 AM

How to Access the "To" Recipient field and update it in outlook fo
 
Thanks for the reply...
To be more clear, I am basically designing a form with some checkboxes
and some info like company name, product name etc.,....that will be sent
to different persons.
when user selects the checkbox corresponding to a particular product
then the Recipient control box,which would be besides the 'To' user
field, should automatically include the specific email address from
contacts rather than user clicking 'To' box and then selecting recipient
from the address book.
The recipient mail address has to change each time user clicks a
different checkbox....i need command for this to include inside:
Sub checkbox1_Click
???
????
End Sub
Sub checkbox2_Click
???
????
End Sub

I know that if its a simple user defined box, i can edit it using
something like: "
but we cannot do that for mail field as it is recipient type and not
text type. so i think there is different command for such mail fields!!

I am not trying to replace recipients, just updating it each time....
and actually after this is done, i will have to add another recipient
for one of the checkboxes...that is second step

I look forward for your suggestions.

Thank You very much for your time and help,
Venkat


*** Sent via Developersdex http://www.developersdex.com ***

Venkat M October 11th 08 02:30 AM

How to Access the "To" Recipient field and update it in outlook fo
 


Thanks for the reply...
To be more clear, I am basically designing a form with some checkboxes
and some info like company name, product name etc.,....that will be sent
to different persons.
when user selects the checkbox corresponding to a particular product
then the Recipient control box,which would be besides the 'To' user
field, should automatically include the specific email address from
contacts rather than user clicking 'To' box and then selecting recipient
from the address book.
The recipient mail address has to change each time user clicks a
different checkbox....i need command for this to include inside:
Sub checkbox1_Click
???
????
End Sub
Sub checkbox2_Click
???
????
End Sub

I know that if its a simple user defined box, i can edit it using
something like: "
but we cannot do that for mail field as it is recipient type and not
text type. so i think there is different command for such mail fields!!

I am not trying to replace recipients, just updating it each time....
and actually after this is done, i will have to add another recipient
for one of the checkboxes...that is second step

I look forward for your suggestions.

Thank You very much for your time and help,
Venkat


*** Sent via Developersdex http://www.developersdex.com ***

Sue Mosher [MVP-Outlook] October 11th 08 03:08 AM

How to Access the "To" Recipient field and update it in outloo
 
In that case, you'd use the Item.Recipients.Add method, which you can look up
in Outlook VBA Help, to add the address to the existing recipients.

To make it really elegant, you may also want to code the reverse process --
iterate the Recipients collection when the user unchecks the box and remove
the recipient with the particular address.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54




"Venkat M" wrote:

Thanks for the reply...
To be more clear, I am basically designing a form with some checkboxes
and some info like company name, product name etc.,....that will be sent
to different persons.
when user selects the checkbox corresponding to a particular product
then the Recipient control box,which would be besides the 'To' user
field, should automatically include the specific email address from
contacts rather than user clicking 'To' box and then selecting recipient
from the address book.
The recipient mail address has to change each time user clicks a
different checkbox....i need command for this to include inside:
Sub checkbox1_Click
???
????
End Sub
Sub checkbox2_Click
???
????
End Sub

I know that if its a simple user defined box, i can edit it using
something like: "
but we cannot do that for mail field as it is recipient type and not
text type. so i think there is different command for such mail fields!!

I am not trying to replace recipients, just updating it each time....
and actually after this is done, i will have to add another recipient
for one of the checkboxes...that is second step

I look forward for your suggestions.

Thank You very much for your time and help,
Venkat


*** Sent via Developersdex http://www.developersdex.com ***


Venkat M October 13th 08 03:03 PM

How to Access the "To" Recipient field and update it in outloo
 

Thank You very much sue...that works perfectly till adding...I was able
to write the loop when user unchecks the box, but i couldn't know which
command to use to clear... Item.Recipients.Remove is giving an error-
after i run the form and deselect the checkbox the error message is
"Type mismatch 'Item.Recipients.Remove'" This is my code, could you
please check it once....
Dim x
Dim n
x=1
n=1
Sub checkbox13_click()
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
If x=1 Then
x=x+1
MyPage.Controls("CheckBox15").Locked = true
MyPage.Controls("CheckBox12").Locked = true
MyPage.Controls("CheckBox14").Locked = true
")
Else
If x= 2*n Then
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
MyPage.Controls("CheckBox15").Locked = false
MyPage.Controls("CheckBox12").Locked = false
MyPage.Controls("CheckBox14").Locked = false
n=n+1
x=x+1
")
Else
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
MyPage.Controls("CheckBox15").Locked = true
MyPage.Controls("CheckBox12").Locked = true
MyPage.Controls("CheckBox14").Locked = true
x=x+1
")
End If
End If
End Sub


I have tried using Delete and Resolve in place of Remove..but same
error...do you have any suggestions in this regard?

Thank You for your help,
Venkat


*** Sent via Developersdex http://www.developersdex.com ***

Venkat M October 13th 08 03:07 PM

How to Access the "To" Recipient field and update it in outloo
 


Thank You very much sue...that works perfectly till adding...I was able
to write the loop when user unchecks the box, but i couldn't know which
command to use to clear... Item.Recipients.Remove is giving an error-
after i run the form and deselect the checkbox the error message is
"Type mismatch 'Item.Recipients.Remove'" This is my code, could you
please check it once....
Dim x
Dim n
x=1
n=1
Sub checkbox13_click()
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
If x=1 Then
x=x+1
MyPage.Controls("CheckBox15").Locked = true
MyPage.Controls("CheckBox12").Locked = true
MyPage.Controls("CheckBox14").Locked = true
")
Else
If x= 2*n Then
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
MyPage.Controls("CheckBox15").Locked = false
MyPage.Controls("CheckBox12").Locked = false
MyPage.Controls("CheckBox14").Locked = false
n=n+1
x=x+1
")
Else
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
MyPage.Controls("CheckBox15").Locked = true
MyPage.Controls("CheckBox12").Locked = true
MyPage.Controls("CheckBox14").Locked = true
x=x+1
")
End If
End If
End Sub


I have tried using Delete and Resolve in place of Remove..but same
error...do you have any suggestions in this regard?

Thank You for your help,
Venkat



*** Sent via Developersdex http://www.developersdex.com ***

Sue Mosher [MVP-Outlook] October 13th 08 03:14 PM

How to Access the "To" Recipient field and update it in outloo
 
If you read the Help topics on the Remove and Delete methods, you'd see that
neither can be used with an address as a parameter. Instead, you should
iterate the Recipients collection, check the value of each Recipient.Address
property, and when you find a match, call Recipient.Delete.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Venkat M" wrote:


Thank You very much sue...that works perfectly till adding...I was able
to write the loop when user unchecks the box, but i couldn't know which
command to use to clear... Item.Recipients.Remove is giving an error-
after i run the form and deselect the checkbox the error message is
"Type mismatch 'Item.Recipients.Remove'" This is my code, could you
please check it once....
Dim x
Dim n
x=1
n=1
Sub checkbox13_click()
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
If x=1 Then
x=x+1
MyPage.Controls("CheckBox15").Locked = true
MyPage.Controls("CheckBox12").Locked = true
MyPage.Controls("CheckBox14").Locked = true
")
Else
If x= 2*n Then
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
MyPage.Controls("CheckBox15").Locked = false
MyPage.Controls("CheckBox12").Locked = false
MyPage.Controls("CheckBox14").Locked = false
n=n+1
x=x+1
")
Else
Set MyPage=Item.GetInspector.ModifiedFormPages("Messag e")
MyPage.Controls("CheckBox15").Locked = true
MyPage.Controls("CheckBox12").Locked = true
MyPage.Controls("CheckBox14").Locked = true
x=x+1
")
End If
End If
End Sub


I have tried using Delete and Resolve in place of Remove..but same
error...do you have any suggestions in this regard?



Venkat M October 13th 08 06:47 PM

How to Access the "To" Recipient field and update it in outloo
 

Thank You very much, that was perfect. But after i run the form and
after filling up all the fields, i am not able to send it, it says "a
field on this form requires a value"
I have tried it many times making sure that i didn't miss any field, but
still same error when i try to send the form....
Could you help me if you have any idea what might be going wrong?

Thanks again for your time,
Venkat



*** Sent via Developersdex http://www.developersdex.com ***

Venkat M October 13th 08 06:48 PM

How to Access the "To" Recipient field and update it in outloo
 

Thank You very much, that was perfect. But after i run the form and
after filling up all the fields, i am not able to send it, it says "a
field on this form requires a value"
I have tried it many times making sure that i didn't miss any field, but
still same error when i try to send the form....
Could you help me if you have any idea what might be going wrong?

Thanks again for your time,
Venkat





*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 07:55 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com