Re: Read from file and display in email body

Tech-Archive recommends: Fix windows errors by optimizing your registry



Try this:

Const ForReading = 1, ForWriting = 2
File="C:\AUTOEXEC.BAT"

Set Fso = CreateObject("Scripting.FileSystemObject")
Set F = Fso.OpenTextFile(File, ForReading)
objEMail.TextBody = F.ReadAll
F.Close


"modemgeek" <modemgeek@xxxxxxxxxxxxxxxxxxxxxxxxx> schreef in bericht
news:443B69D5-E98B-4595-ABB8-6536BE227CBF@xxxxxxxxxxxxxxxx
>I would like this script to read from a text file and insert it into the
>body
> of the email. This is what I have so far. Does anyone know how I can do
> this?
>
> 'Set the global variables.
> myName = "Tester"
> mailFrom = "test1@xxxxxxxxx"
> mailTo = "jtest@xxxxxxxx"
> mailCC = "test@xxxxxxxx"
> mailSubject = "Test"
> HTMLBody ="<h1>Please review and reply to test2@xxxxxxxx with the
> following:</h1><br>" & _
> "1. Information in report has been reviewed and is accurate<br>" & _
> "2. Information in report is not accurate and provide corrections<br><br>"
> mailHost = "127.0.0.1"
>
> Set objEmail = CreateObject("CDO.Message")
>
> objEmail.From = myName & " <" & mailFrom & ">"
> objEmail.To = mailTo
> objEmail.CC = mailCC
> objEmail.AddAttachment "c:\scripts\groupmembership2.txt"
> objEmail.Subject = mailSubject
> objEmail.HTMLBody = HTMLBody
> objEmail.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2
> objEmail.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/smtpserver";) = _
> MailHost
> objEmail.Configuration.Fields.Item _
> ("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25
> objEmail.Configuration.Fields.Update
> objEmail.Send


.



Relevant Pages

  • Re: problem using FileSystemObject
    ... > When I came to the FileSystemObject I found IIS hangs on OpenTextFile. ... > I'm using the Script Debugger and executing one command at a time and it ... Set fso = Server.CreateObject ... > ' fails here ...
    (microsoft.public.inetserver.asp.general)
  • Re: Running FTP script and waiting for answer...can I set "timeout"
    ... Try this command to change default script engine to cscript from wscript ... I'm running ftp "run command" every 2 minuteto lookup new ... I can give you a copy of my script for you to scan... ... Set Fso = Wscript.Createobject ...
    (microsoft.public.scripting.vbscript)
  • Re: Running FTP script and waiting for answer...can I set "timeout"
    ... Try this command to change default script engine to cscript from wscript ... I'm running ftp "run command" every 2 minuteto lookup new ... I can give you a copy of my script for you to scan... ... Set Fso = Wscript.Createobject ...
    (microsoft.public.scripting.vbscript)
  • Re: Deploying user list to workgroup
    ... I've pasted the script below with the requested modifications and some ... If left blank, accounts will ... be members of Users group.", ... (members, ForReading) ...
    (microsoft.public.win2000.general)
  • Re: Task Scheduler IGNORES duration
    ... task stopped triggering based on "start every minute" for a "duration ... Btw my original backup check script ... Set fso = CreateObject ...
    (microsoft.public.windows.server.general)