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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 97 auto email how to write VBScript in VBA

Status
Not open for further replies.

vincerhodes

Programmer
May 21, 2008
3
GB
I've set up an email function in an access database, The email is compiled by using VBA to write HTML code to Outlook 2002 using the built in Outlook commands.

Everything works fine so far, but I would like to include some simple VBScript to allow the user to select an option (in this case accept or decline the date/time specified) and email the response back...

The problem is that in VBA you have to write HTML continuously, enclosed in quotes. But VBScript uses a newline between code instructions, does anyone know if there is a newline character I can write into the vba code so I can write VBScript in this manner.

See below for an example of some HTML written in VBA.

****
Sub helloWorld()

dim OutApp as Object
dim OutMail as Object

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.createitem(0)

dim exampleVariable As String

exampleVariable = "<HTML><head><title><p>Hello world</p></title></head><body><p>Please select the option below and click 'send response'</p><p><SCRIPT LANGUAGE="VBScript">'Code Goes Here'</SCRIPT></body></HTML>"

OutMail.To = "first.last@somewhere.com"
OutMail.Subject = "Hello World!"
OutMail.HTMLBody = exampleVariable

OutMail.Display

Set OutMail = Nothing

End Sub

****

Please can someone let me know if this is even possible or what the alternative is.

Thanks,

J
 
Is this a VBA question or a VBScript question?

If it's VBA - you need forum707

If it's vbscript - look at the vbNewLine statement

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
I suppose it's more VBA than VBScript, i've posted in both forums to see if anyone from either background knows the solution since to know the solution you would have had to use both VBA and VBScript.

The question could be worded as how can you embed VBScript in a HTML document written with VBScript, i.e. you could have a button on a web page that composes an email using outlook with some VBScript in it....

Thanks,

J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top