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

Filesystem object

Status
Not open for further replies.

ton9

Programmer
Apr 17, 2001
5
US
I am working on trying to send an html email. I have created the text file that contains the email and the .vbs file that will read in the text file and ultimately send out an email. Problem is I have the code that can read in the text file into a variable but now i am not sure of where to go from here. I know I need to somehow use the variable which now contains the email text and send my email to a lot of people. Below is the code I have in my .vbs file. Can anyone guide me into the next step.

Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile("c:\newsletter.txt", ForReading, False)
Do While f.AtEndOfStream <> True
strLine = f.ReadLine
Loop
f.Close
Set f = Nothing
Set fso = Nothing
 
Hi,

I'll hope this code will help you.
Code:
<%
Dim myMail
Dim fso, f
Set myMail = CreateObject(&quot;CDONTS.NewMail&quot;) 
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f = fso.OpenTextFile(&quot;c:\newsletter.txt&quot;, 1, False)
Do While f.AtEndOfStream <> True
  strLine = f.ReadLine  
Loop
f.Close   
Set f = Nothing
Set fso = Nothing
' .From = &quot;name <email>&quot;
myMail.From = &quot;Luís Nuno Silva <lnors@ieeta.pt>&quot;
' .to = &quot;name1 <email1>; name2 <email2>, ..., nameN <emailN>&quot;
myMail.To = &quot;Luís Silva <lnors@ieeta.pt>;Luís Nuno Silva <lnors@ieeta.pt>;Luís N O R Silva <lnors@ieeta.pt>&quot; 
myMail.Subject = &quot;Sample Message&quot; 
myMail.BodyFormat = 0 
myMail.MailFormat = 0 
myMail.Body = strLine
' myMail.AttachFile &quot;E:\[URL unfurl="true"]wwwroot\warning.gif&quot;,[/URL] &quot;teste.gif&quot;
myMail.Importance = 0
myMail.Send 
Set myMail = Nothing
%>
[code]

  For further information use [URL unfurl="true"]http://msdn.microsoft.com/library/psdk/cdo/_denali_newmail_object_cdonts_library_.htm.[/URL]

 Regards,
Luís Silva
 
Code:
Do While f.AtEndOfStream <> True
  strLine = f.ReadLine  
Loop
Gets you only the last line.
Why not use
Code:
strLine = f.readAll
Code:
Do While f.AtEndOfStream <> True
    if Len(strLine) > 0 then
        strLine = strLine & vbcrlf & f.ReadLine
    else
        strLine = f.Readline
    endif  
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top