dynamically adding text to a mail message

F

Frank Rice

I would like to add custom text to the bottom of my e-mail messages at
runtime, just below the signature block. I will add text to the form
dynamically in VBA when I create a message based on the form.

To do this I created a custom form based on the Message template. I then
added a text box to the form and set the Text property to some text so I can
see that the text box is actually on the form. That said, I'm having a
problem.

I can't drop the text box directly onto the body of the form. When I try to,
it puts the box on the outside of the body area in the gridded area. If I
play around with the form to finally get a text box in the body area, when I
view the form, the text box (with the text I added) doesn't show up when I
click Run the Form.
I have two questions:
Is there a way to add a text box to the body of a message using a text box?

More important yet, is there a way that I can add text to the bottom of a
message at runtime?

Thanks for your help.
 
G

Guest

It sounds like you are trying to place a control onto the Message control,
which contains the body of the e-mail message. This isn't "designable"; it
is a special text box much like the one you are tyring to put inside of it.

This control is bound to the Item.Message property. For any control that
exists or that you add to a form, it is usually associated or bound to a
field/property. Rather than setting a control's Text property, it is better
practice to set the value of the property that it is bound to. So instead of
TextBox1.Text = "My Value", you would set Item.Body = "My Value", and the
control will display this value if it is bound to this property.

If you want to modify the message body at run time, it is usually best to do
this during the Item_Open event.
 
F

Frank Rice

Thanks, Eric. I'll give that a try. One additional question:

I've created a custom form and placed it in the Personal Forms Library. How
do I reference a custom form (and the controls on it ) in that library in
VBA?

Thanks again.
 
F

Frank Rice

Thanks, Eric. I'll give that a try. One additional question:

I've created a custom form and placed it in the Personal Forms Library. How
do I reference a custom form (and the controls on it ) in that library in
VBA?

Thanks again.
 
G

Guest

In VBA, use the Inspector.ModifiedFormPages property to return the Pages
object. Then you can access the Page object's Controls collection to refer
to a custom control by name. If you are using VBScript behind the form, use
the intrinsic Item object to access the Inspector object via
Item.GetInspector.

So this will work in VBA and VBScript, once you have an Inspector object:

Set objMyControl =
objMyInspectorObject.ModifiedFormsPages("P.2").Controls("MyControlName")

Keep in mind that you don't usually access an item created from a custom
form by getting a reference to the published version of the form that is
stored in the Personal Forms library. These are actually hidden messages in
a hidden folder (see http://tinyurl.com/duxxt).

To get an object handle to an item created on a form published in the
Personal Forms library, you must use the name of the published form's message
class, and add it to the Items collection of the folder where you want to
store this form:

Set objFolder = Application.ActiveExplorer.CurrentFolder
Set objItem = _
objFolder.Items.Add("IPM.Note.Your Custom Form")
objItem.Display

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
F

Frank Rice

Thanks again, Eric. This is a big help.
Eric Legault said:
In VBA, use the Inspector.ModifiedFormPages property to return the Pages
object. Then you can access the Page object's Controls collection to
refer
to a custom control by name. If you are using VBScript behind the form,
use
the intrinsic Item object to access the Inspector object via
Item.GetInspector.

So this will work in VBA and VBScript, once you have an Inspector object:

Set objMyControl =
objMyInspectorObject.ModifiedFormsPages("P.2").Controls("MyControlName")

Keep in mind that you don't usually access an item created from a custom
form by getting a reference to the published version of the form that is
stored in the Personal Forms library. These are actually hidden messages
in
a hidden folder (see http://tinyurl.com/duxxt).

To get an object handle to an item created on a form published in the
Personal Forms library, you must use the name of the published form's
message
class, and add it to the Items collection of the folder where you want to
store this form:

Set objFolder = Application.ActiveExplorer.CurrentFolder
Set objItem = _
objFolder.Items.Add("IPM.Note.Your Custom Form")
objItem.Display
 

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