Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 17th, 2005, 10:17 AM
stickyfingaz stickyfingaz is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 stickyfingaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 21 sec
Reputation Power: 0
Cool HELP?!?! Trying to extract txt file content and send via email

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

Reply With Quote
  #2  
Old March 22nd, 2005, 04:32 PM
werD's Avatar
werD werD is offline
Certified Abuser
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2005
Location: Line 73 ---^
Posts: 1,046 werD User rank is First Lieutenant (10000 - 20000 Reputation Level)werD User rank is First Lieutenant (10000 - 20000 Reputation Level)werD User rank is First Lieutenant (10000 - 20000 Reputation Level)werD User rank is First Lieutenant (10000 - 20000 Reputation Level)werD User rank is First Lieutenant (10000 - 20000 Reputation Level)werD User rank is First Lieutenant (10000 - 20000 Reputation Level)werD User rank is First Lieutenant (10000 - 20000 Reputation Level)werD User rank is First Lieutenant (10000 - 20000 Reputation Level)  Folding Points: 20652 Folding Title: Starter FolderFolding Points: 20652 Folding Title: Starter Folder
Time spent in forums: 1 Week 4 Days 20 h 37 m 12 sec
Reputation Power: 127
Cool

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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > HELP?!?! Trying to extract txt file content and send via email


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway