Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill in textboxes on Outlook Form from Word

Status
Not open for further replies.

grannyM

Programmer
Nov 26, 2002
39
0
0
US
I'm using Word and Outlook 2000. I have a simple function that I use to send an email from Word. In the version I have below, it uses an Outlook template and it works just great. But now they've decided they want to add some textboxes to the Outlook template that need to be filled in by the macro before it sends the template.

I have programmed in Word, Excel and Access, but never in Outlook. I have spent several days researching Word references and Outlook references and have not been able to figure out how to fill in the textboxes on the Outlook template before sending it. Since the textboxes are named (in this case "txtPlanName" for one), it seems like it should be doable. From my research, it looks possible, but everything I've tried hasn't worked.

Here is my basic code without trying to fill in the textboxes:
Code:
Function SendEmail(eeEmail$, EmailSubject$, SendNow As Boolean)
'create email with attachment

Dim OlApp As Outlook.Application
Dim SafeItem As Object
Dim oItem As Object
Dim utils As Object
Dim nspnamespace As Outlook.NameSpace

Set OlApp = Outlook.Application
Set nspnamespace = OlApp.GetNamespace("Mapi")
Set SafeItem = CreateObject("SafeOutlook.SafeMailItem")
Set oItem = OlApp.CreateItemFromTemplate("f:\winword\template\test.oft")
Set utils = CreateObject("cpioutlook.MAPIUtils")

SafeItem.Item = oItem
SafeItem.Recipients.Add eeEmail$
SafeItem.Recipients.ResolveAll
SafeItem.Subject = EmailSubject$

if SendNow = True then
   SafeItem.Send
else
   SafeItem.Display
end if

Set OlApp = Nothing
Set nspnamespace = Nothing
Set SafeItem = Nothing
Set oItem = Nothing

End Function

Thanks, any help is appreciated. [sad]


 



"...textboxes to the Outlook template that need to be filled in by the macro "

What is the function of these text boxes?

Will the values in the text boxes be changed by users?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks Skip for responding.

When a user runs the Word Macro, it would pull the applicable client information (such as Client Contact Name, etc) from a SQL table and insert it into the textboxes on Outlook template, then email the template to the appropriate Department. In Word or Access I would just put something like:
Code:
 textbox1.text = ClientName
I know I could accomplish something similar by using a string variable and just inserting all the text into the body of an email, but they are wanting to use a template that will make certain items jump out at the person receiving the email.
 




A text box is a CONTROL, that expects a response.

In this case, its the wrong thing.

If you want to draw attnetion to a string, there are any number of ways to FORMAT a MailMerge field, to make it "jump out" at you. Don't make it harder than it has to be.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sorry it took me so long to get back to this. So let's say I use labels instead of textboxes. It's still the same issue, I cannot figure out how to set the label captions through code. What they are wanting is a frame on the left side of the email that holds all the pertinent client information, then a message box on the right side of the email where they can type their comments. This would be sort of an inter-department email. When one department sends the other department an email about a client, all of the client information would there for the receiving department.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top