Form - Specific "To" Recipient value

Status
Not open for further replies.
D

daniel_l_v

Created a simple "Phone Message" style custom Outlook 2007 form.

Want to set the "To" field to a specific email address that customers cannot

change, have not been able to do this.

Can anyone advise whether the "To" field can be set programmatically prior

to the message being sent, so that it always gets sent to the same recipient?
 
S

Sue Mosher [MVP]

Sure, that's possible. Remove the address controls from the form and try

this code:

Function Item_Open()

If Item.Sent <> False Then

Item.To = "myaddress@mycompany.com"

Item.Recipients.ResolveAll

End If

End Function

Function Item_Send()

Item.To = "myaddress@mycompany.com"

End Function

The Item.To statement is in both events to make sure there's a recipient

already present when the user tries to send the item. This won't prevent a

user from bringing up the Address Book dialog and changing the recipients,

but the Item_Send code will override any changes they've made.

You are planning to publish this form to the Organizational Forms library or

to each user's Personal Forms library, correct?

Sue Mosher

"daniel_l_v" <daniellv> wrote in message

news:96F6BE28-D254-4AD1-81C5-15166093AF1F@microsoft.com...
> Created a simple "Phone Message" style custom Outlook 2007 form.
> Want to set the "To" field to a specific email address that customers
> cannot
> change, have not been able to do this.

> Can anyone advise whether the "To" field can be set programmatically prior
> to the message being sent, so that it always gets sent to the same
> recipient?
>
 
D

daniel_l_v

Hi Sue,

Thanks for the code.

I've put the code you suggested in the script editor and saved my form.

However, whilst the code doesn't give any errors, it doesn't seem to

actually trigger. I've put in a couple of MsgBox statesments to check, but

neither seems to run.

Yes - The form will be published eventually to Organizational Forms.

Is there something I might me missing that could be stopping the code from

actually running? Do I need any header or tags in the script to ensure it is

in the correct format?

Just checking, I should be putting the code in the "View Code" Script

Editor, and NOT in a Visual Basic project.
 
S

Sue Mosher [MVP]

I don't know what you mean by "saved my form." Code runs only on published

forms. You'll need to publish it to get it to work.

Sue Mosher

"daniel_l_v" <daniellv> wrote in message

news:037E7839-8090-4049-A885-84FBE42EE316@microsoft.com...
> Hi Sue,

> Thanks for the code.

> I've put the code you suggested in the script editor and saved my form.

> However, whilst the code doesn't give any errors, it doesn't seem to
> actually trigger. I've put in a couple of MsgBox statesments to check,
> but
> neither seems to run.

> Yes - The form will be published eventually to Organizational Forms.

> Is there something I might me missing that could be stopping the code from
> actually running? Do I need any header or tags in the script to ensure it
> is
> in the correct format?

> Just checking, I should be putting the code in the "View Code" Script
> Editor, and NOT in a Visual Basic project.
 
D

daniel_l_v

Sue, by "save my form" I meant exactly that, you can save a form as an OFT

file whilst working on it.

I've published but still not working.

Is the "Item" an object representing the message itself? I can't find

"Item" in the VB Script Object Browser.
 
S

Sue Mosher [MVP]

As I said, only published forms run code. Forms saved as .oft files don't.

Item is an intrinsic object in custom form code representing the current

item, just as Application represents the running Outlook.Application object.

Sue Mosher

"daniel_l_v" <daniellv> wrote in message

news:935F5C0A-37CD-437C-87A0-70CF714D2666@microsoft.com...
> Sue, by "save my form" I meant exactly that, you can save a form as an OFT
> file whilst working on it.

> I've published but still not working.

> Is the "Item" an object representing the message itself? I can't find
> "Item" in the VB Script Object Browser.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M form or template associated to a specific email recipient Outlook VBA and Custom Forms 3
D Re: Opening a specific Custom form with a macro Outlook VBA and Custom Forms 3
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
V Form data not sending for some users Outlook VBA and Custom Forms 1
H Custom Outlook Contact Form VBA Outlook VBA and Custom Forms 1
witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
A VBscript stops running after updating form Outlook VBA and Custom Forms 0
witzker HowTo start a macro with an Button in OL contact form Outlook VBA and Custom Forms 12
D Emailed form is blank Outlook VBA and Custom Forms 0
F Validation on custom task form after task acceptance Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
V Date and/or time error in Outlook Form Outlook VBA and Custom Forms 0
A Form Position with Dual Monitors Outlook VBA and Custom Forms 2
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
M VbScript for Command Button on Contacts Custom Form Using Outlook 1
G Other users can't see P.2 with custom fields in Form Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
L Custom Form Tutoral? Outlook VBA and Custom Forms 6
D Lost Access to Custom Form Outlook VBA and Custom Forms 4
A Form style totally changes Outlook VBA and Custom Forms 2
M vCard does not have user-defined fields from my custom contact form (365) Using Outlook 1
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
V Making a Date field mandatory in outlook form Outlook VBA and Custom Forms 2
R Add 'Company' to Select Names Form Using Outlook 1
Victor_50 Outlook 2013 Custom Contact Form starts with "E-mail 2" Outlook VBA and Custom Forms 2
C Custom Form (seperate layout pages and message reading pane) Outlook VBA and Custom Forms 0
C Reading Pane for Custom Form Outlook VBA and Custom Forms 2
N Custom Form Controls Not Visible To Recipient Outlook VBA and Custom Forms 3
BretAB Is it possible to add a lookup field to a Message form? Outlook VBA and Custom Forms 4
Randy Redekopp How To Merge Contact Info to Email Custom Form Template Using Outlook 2
D Problem with custom form including _DocSiteControl1 Outlook VBA and Custom Forms 0
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
J Program Checkbox that will activate a text box in a Outlook fallible form. Outlook VBA and Custom Forms 1
W Message class changes of a custom form changes to the default form Using Outlook 2
A Possible to hide ribbon with custom appointment form? Outlook VBA and Custom Forms 3
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
Andrew Quirl Custom form to route requests based on input criteria Outlook VBA and Custom Forms 1
Daniel Schunk User-defined form arrives empty at the recipient Using Outlook 3
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
W Setting up a custom form Outlook VBA and Custom Forms 2
A Greyed out checkbox in custom form Outlook VBA and Custom Forms 4
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
J Approval Form Outlook VBA and Custom Forms 0
G Mass Updating Contact form used Outlook VBA and Custom Forms 8
N Creating a button or link to a form in the Organizational Forms Library Outlook VBA and Custom Forms 3
H VB script in outlook form doesn't work anymore Outlook VBA and Custom Forms 2
J autocomplete function in custom form Using Outlook 1
D Custom form with html hyperlink Outlook VBA and Custom Forms 7
D Add Tetxbox at form open Outlook VBA and Custom Forms 1

Similar threads

Top