Solved Using CDO, selecting the text file template via a textbox on a form

mousemat

Completely Self Taught
Local time
Today, 22:05
Joined
Nov 25, 2002
Messages
233
Hi

I have been using the CDO method to send emails to people using text templates and placeholders, which work really well.

What I'd like to do is determine at the time of sending the emails, which template to use. Currently the text template is written within the module itself.

Code:
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the file for reading
Set f = fso.OpenTextFile("c:\AccessTextFiles\letterTest.txt", ForReading)

'The ReadAll method reads the entire file into the variable BodyText
BodyText = f.ReadAll
'Close the file

Is it possible to use a textbox from the form that creates the recordset to set the Text Template
 
You could try using a variable. For example:
Code:
Set f = fso.OpenTextFile(TextFilePath, ForReading)
 
Hi DBGuy

How would I reference the textbox from the form?
 
Hi DBGuy

How would I reference the textbox from the form?
You could use a Form reference. For example:
Code:
Dim TextFilePath As String
TextFilePath = Forms!FormName.TextboxName
Hope that helps...
 
Excellent. It's been a long Christmas period. All working as required.
 

Users who are viewing this thread

Back
Top Bottom