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

Email Attachment Not There

Status
Not open for further replies.

winston1984

IS-IT--Management
Jun 4, 2004
17
0
0
GB
I have the following code, but everything works well, except there is no attachment. The file exists afterwards but it just doesn't attach it.

Function Main()

On Error Resume Next

dim strRecord
dim strEmailBody
dim objFSO
dim objStream
dim objMail
dim objResults
dim strFileToAttach

strFileToAttach = "E:/SQLOUTPUT/PRICE.TXT"

const OUTPUT_FILE = "E:\SQLOUTPUT\PRICE.TXT"
const EXECUTIVE_EMAILS = "lewis@lharvey.com"
const fsoForWriting = 2

set objFSO = CreateObject("Scripting.FileSystemObject")
set objResults = DTSGlobalVariables("gResults").Value

set objStream = objFSO.OpenTextFile(OUTPUT_FILE, fsoForWriting, true)

'Loop through the records and output each one
'to a file.

while not objResults.EOF
strRecord = "ISONID = " & objResults.Fields(0).value & vbCrLf &_
"ISON7PRICE = " & objResults.Fields(1).value & vbCrLf &_
"STOCK PRICE = " & objResults.Fields(3).value

objStream.WriteLine(strRecord)
objStream.WriteBlankLines(1)
objResults.MoveNext
wend

'Sending a text email with an attached file

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.Sender = "me@my.com"
objMessage.To = "lewis@lharvey.com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment strFileToAttach
objMessage.Send


if err.count = 0 then
Main = DTSTaskExecResult_Success
else
Main = DTSTaskExecResult_Failure
end if

End Function



Running MS Server 2003 SBE.
 
strFileToAttach = "E:[highlight]/[/highlight]SQLOUTPUT[highlight]/[/highlight]PRICE.TXT"
const OUTPUT_FILE = "E:[highlight]\[/highlight]SQLOUTPUT[highlight]\[/highlight]PRICE.TXT"
Is it intentionally ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Furthermore, objStream is never closed nor released.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top