|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I am trying to send the contents of a text file, via email which I have written in vbs. Below is the code that generates the email: ' Force explicit declaration of all variables. Option Explicit 'Define all the variables Dim FileSO Dim FileName Dim DocName Dim DisplayMsg Dim objOutlook Dim objOutlookMsg Dim objOutlookRecip Dim Today,Expiretime,NowTime Set FileSO = CreateObject("Scripting.FileSystemObject") ' Create the Outlook session. Set objOutlook = CreateObject("Outlook.Application") ' Set expiry time for 3 hours from now Today = Date NowTime = Now Expiretime = DateAdd("h",13,Today) if (ExpireTime < NowTime) then Expiretime = DateAdd("h",8,NowTime) End if ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(0) ' Add the To recipient(s) to the message. set objOutlookRecip = objOutlookMsg.Recipients.Add("Sticky Fingaz") objOutlookRecip.Type = 1 ' 0 = Originator, 1 = TO, 2 = CC ' Set the Subject, Body, and Importance of the message. objOutlookMsg.Subject = "Greetings" objOutlookMsg.Body = vbCrLf & "Hello" & DocName & vbCrLf & "How are you?" objOutlookMsg.Importance = 1 '0 = low, 1 = normal, 2 = High importance objOutlookMsg.Expirytime = Expiretime ' Resolve each Recipient's name. For Each ObjOutlookRecip In objOutlookMsg.Recipients objOutlookRecip.Resolve Next objOutlookMsg.Save objOutlookMsg.Send Set objOutlook = Nothing Now, could someone please tell me how I may enter the content of a text file as the body of the email? Any help will be much appreciated. Thanks. Last edited by stickyfingaz : March 17th, 2005 at 10:19 AM. Reason: Title |
|
#2
|
||||
|
||||
|
Code:
Const forReading = 1
Set objFSO = CreateObject("Scripting.FilesystemObject")
Set objFile = objFSO.OpenTextFile("C:\textfile.txt", forReading)
strContents = objFile.ReadAll
Wscript.Echo strContents
objFile.Close
The preceding code will echo the contents of a text file on the screen. That code can be modified for your application. The variable for all the words in the text file is called "strContents" Add this code to your page minus the Wscript.echo part and call the strContents Variable in your email script |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > HELP?!?! Trying to extract txt file content and send via email |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|