chris
Fri Apr 25 12:23:01 CDT 2008
Pegasus,
Your simple script hangs in the same place my script hangs in. The
AddAttachment statement. As I mentioned in my first message, this script has
worked fine up until about 2 to 3 weeks ago. Some patch or other software is
causing this problem. I am looking to see if anyone else has the same
problem or can point out a place to start looking for what is causing the
problem. I have removed all the patches that have been loaded in the last
month, but it still hangs.
Thanks,
Chris
--
No matter where you go, there you are...
"Pegasus (MVP)" wrote:
>
> "Chris" <chris@discussions.microsoft.com> wrote in message
> news:7382AA24-45B8-4054-8D55-FDFA5BE27526@microsoft.com...
> > Here is the script in its entirety:
> > Const ForReading = 1
> > Set objArgs = WScript.Arguments
> > attachfile = 0
> > If WScript.Arguments.Count < 3 Then
> > Wscript.echo "You do not have the correct number of arguments."
> > Wscript.quit
> > ElseIf WScript.Arguments.Count = 3 then
> > strSubject = objArgs(0)
> > strTolist = objArgs(1)
> > strBodyfile = objArgs(2)
> > attachfile = 0
> > ElseIf WScript.Arguments.Count = 4 then
> > strSubject = objArgs(0)
> > strTolist = objArgs(1)
> > strBodyfile = objArgs(2)
> > strFileattachment = objArgs(3)
> > attachfile = 1
> > Else
> > Wscript.echo "You do not have the correct number of arguments."
> > Wscript.quit
> > End If
> > Set objEmail = Nothing
> > Set objEmail = CreateObject("CDO.Message")
> > objEmail.From = "me@where.com"
> > objEmail.Subject = strSubject
> > objEmail.To = strTolist
> > objEmail.Textbody = ""
> > strScriptPath = Wscript.ScriptFullName
> > strScriptName = Wscript.ScriptName
> > strScriptFolder = Left(strScriptPath, Len(strScriptPath) -
> > Len(strScriptName) - 1)
> > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > If objFSO.FileExists(strScriptFolder & "\" & strBodyfile) Then
> > Set objTextFile = objFSO.OpenTextFile(strScriptFolder & "\" &
> > strBodyfile, ForReading)
> > Do while objTextFile.AtEndOfStream <> True
> > Record = objTextFile.ReadLine
> > objEmail.Textbody = objEmail.Textbody & Record & VbCrLf
> > Loop
> > objTextFile.Close
> > Else
> > objEmail.Textbody = objEmail.Textbody & "No message body file was
> > specified." & VbCrLf
> > End If
> > objEmail.Textbody = objEmail.Textbody & VbCrLf
> > Wscript.echo "Added Body"
> >
>
> I tried your script and got it to work exactly once but never again.
> I was unable to track down what causes the problem and ran out
> of time after a while. Instead of persisting, I attach a generic mailing
> script for your convenience. You should easily be able to tailor it
> to your own environment. And it works!
>
> A couple of remarks to your own script:
> - I wonder about the wisdom of keeping your data files in the same
> folder as your script file. My strong preference is never to mix
> programs with data. I think it's a bad habit that can easily cause
> problems.
> - You build up your "Record" variable by adding lines from your
> "body" file, but you never initialise this variable. While VB Script
> initialises variables to "Null", it is dangerous for programmers to
> assume this. Robust programming requires you to initialise
> Record = "" before using it.
>
> schema = "
http://schemas.microsoft.com/cdo/configuration/"
> Set objEmail = CreateObject("CDO.Message")
> With objEmail
> .From = "Pegasus@pegasus.com"
> .To = "peg@yahoo.com"
> .Subject = "Test Mail #1"
> .Textbody = "The quick brown fox"
> .AddAttachment "d:\temp\robocopy.txt"
> With .Configuration.Fields
> .Item (schema & "sendusing") = 2
> .Item (schema & "smtpserver") = "mail.smtp.com"
> .Item (schema & "smtpserverport") = 25
> .Item (schema & "smtpauthenticate") = cdoBasic
> ' .Item (schema & "sendusername") = "pegasus"
> ' .Item (schema & "sendpassword") = "smtp"
> End With
> .Configuration.Fields.Update
> .Send
> End With
>
>
>