Here is the snippet of code that is doing the Add Attachment:

If attachfile = 1 then
strattachment = strScriptFolder & "\" & strFileattachment
Wscript.echo "Attachment: " & strattachment
If objFSO.FileExists(strattachment) Then
Wscript.echo "Attachment exists"
objEmail.AddAttachment(strAttachment)
Wscript.echo "Attachment added"
End If
End If


This worked within the last 3 weeks. Some patch or other software was
loaded and now when the script gets to the add attachment statement, it hangs
and uses 50% of the processor. I have tried uninstalling all the patches I
can find that have been loaded in the last month, but it still hangs. There
is no error and nothing in the event logs?

Has anyone else seen this problem?

Thanks in advance,
Chris
--
No matter where you go, there you are...

Re: Script to Email attachment hangs on the AddAttachment statement by Pegasus

Pegasus
Fri Apr 25 10:00:54 CDT 2008


"Chris" <chris@discussions.microsoft.com> wrote in message
news:63969700-9A11-415E-BB5D-D6EADD0FD3C9@microsoft.com...
> Here is the snippet of code that is doing the Add Attachment:
>
> If attachfile = 1 then
> strattachment = strScriptFolder & "\" & strFileattachment
> Wscript.echo "Attachment: " & strattachment
> If objFSO.FileExists(strattachment) Then
> Wscript.echo "Attachment exists"
> objEmail.AddAttachment(strAttachment)
> Wscript.echo "Attachment added"
> End If
> End If
>
>
> This worked within the last 3 weeks. Some patch or other software was
> loaded and now when the script gets to the add attachment statement, it
> hangs
> and uses 50% of the processor. I have tried uninstalling all the patches
> I
> can find that have been loaded in the last month, but it still hangs.
> There
> is no error and nothing in the event logs?
>
> Has anyone else seen this problem?
>
> Thanks in advance,
> Chris

It might be useful to post the whole script relevant to the
mailing functionality.



Re: Script to Email attachment hangs on the AddAttachment statemen by chris

chris
Fri Apr 25 10:12:02 CDT 2008

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"


objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"mail.where.com"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
Wscript.echo "Fields Updated"

If attachfile = 1 then
strattachment = strScriptFolder & "\" & strFileattachment
Wscript.echo "Attachment Folder: " & strattachment
If objFSO.FileExists(strattachment) Then
Wscript.echo "Attachment exists"
objEmail.AddAttachment(strattachment)
Wscript.echo "Attachment added"
End If
End If
Wscript.echo "Attached File"

objEmail.Send


Wscript.echo "Sending Email"

Set objEmail = Nothing
Wscript.quit


--
No matter where you go, there you are...


"Pegasus (MVP)" wrote:

>
> "Chris" <chris@discussions.microsoft.com> wrote in message
> news:63969700-9A11-415E-BB5D-D6EADD0FD3C9@microsoft.com...
> > Here is the snippet of code that is doing the Add Attachment:
> >
> > If attachfile = 1 then
> > strattachment = strScriptFolder & "\" & strFileattachment
> > Wscript.echo "Attachment: " & strattachment
> > If objFSO.FileExists(strattachment) Then
> > Wscript.echo "Attachment exists"
> > objEmail.AddAttachment(strAttachment)
> > Wscript.echo "Attachment added"
> > End If
> > End If
> >
> >
> > This worked within the last 3 weeks. Some patch or other software was
> > loaded and now when the script gets to the add attachment statement, it
> > hangs
> > and uses 50% of the processor. I have tried uninstalling all the patches
> > I
> > can find that have been loaded in the last month, but it still hangs.
> > There
> > is no error and nothing in the event logs?
> >
> > Has anyone else seen this problem?
> >
> > Thanks in advance,
> > Chris
>
> It might be useful to post the whole script relevant to the
> mailing functionality.
>
>
>

Re: Script to Email attachment hangs on the AddAttachment statemen by Pegasus

Pegasus
Fri Apr 25 11:33:37 CDT 2008


"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



Re: Script to Email attachment hangs on the AddAttachment statemen by chris

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
>
>
>

Re: Script to Email attachment hangs on the AddAttachment statemen by Pegasus

Pegasus
Fri Apr 25 12:37:51 CDT 2008

I would now reboot the machine in "Safe Mode with Networking"
and try again.


"Chris" <chris@discussions.microsoft.com> wrote in message
news:4F59A03A-24A5-4690-B782-00A4E7AE9212@microsoft.com...
> 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
>



Re: Script to Email attachment hangs on the AddAttachment statement by dopegroove

dopegroove
Sat Apr 26 05:35:51 CDT 2008

On Apr 25, 10:22 am, Chris <ch...@discussions.microsoft.com> wrote:
> Here is the snippet of code that is doing the Add Attachment:
>
> If attachfile = 1 then
> strattachment = strScriptFolder & "\" & strFileattachment
> Wscript.echo "Attachment: " & strattachment
> If objFSO.FileExists(strattachment) Then
> Wscript.echo "Attachment exists"
> objEmail.AddAttachment(strAttachment)
> Wscript.echo "Attachment added"
> End If
> End If
>
> This worked within the last 3 weeks. Some patch or other software was
> loaded and now when the script gets to the add attachment statement, it hangs
> and uses 50% of the processor. I have tried uninstalling all the patches I
> can find that have been loaded in the last month, but it still hangs. There
> is no error and nothing in the event logs?
>
> Has anyone else seen this problem?
>
> Thanks in advance,
> Chris
> --
> No matter where you go, there you are...

Maybe you should try Blat instead (http://www.blat.net/). I know
outlook has some issues sending e-mail automatically.

Re: Script to Email attachment hangs on the AddAttachment statemen by chris

chris
Fri May 02 11:58:03 CDT 2008

I tried rebooting in Safe Mode with Networking and still have the same problem.

Any other suggestions?

Thanks,
Chris

--
No matter where you go, there you are...


"Pegasus (MVP)" wrote:

> I would now reboot the machine in "Safe Mode with Networking"
> and try again.
>
>
> "Chris" <chris@discussions.microsoft.com> wrote in message
> news:4F59A03A-24A5-4690-B782-00A4E7AE9212@microsoft.com...
> > 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
> >
>
>
>

Re: Script to Email attachment hangs on the AddAttachment statemen by chris

chris
Fri May 02 12:00:08 CDT 2008

I am not really using Outlook. In fact I don't have outlook installed. This
script uses a CDO.message object.

Thanks,
Chris

--
No matter where you go, there you are...


"dopegroove" wrote:

> On Apr 25, 10:22 am, Chris <ch...@discussions.microsoft.com> wrote:
> > Here is the snippet of code that is doing the Add Attachment:
> >
> > If attachfile = 1 then
> > strattachment = strScriptFolder & "\" & strFileattachment
> > Wscript.echo "Attachment: " & strattachment
> > If objFSO.FileExists(strattachment) Then
> > Wscript.echo "Attachment exists"
> > objEmail.AddAttachment(strAttachment)
> > Wscript.echo "Attachment added"
> > End If
> > End If
> >
> > This worked within the last 3 weeks. Some patch or other software was
> > loaded and now when the script gets to the add attachment statement, it hangs
> > and uses 50% of the processor. I have tried uninstalling all the patches I
> > can find that have been loaded in the last month, but it still hangs. There
> > is no error and nothing in the event logs?
> >
> > Has anyone else seen this problem?
> >
> > Thanks in advance,
> > Chris
> > --
> > No matter where you go, there you are...
>
> Maybe you should try Blat instead (http://www.blat.net/). I know
> outlook has some issues sending e-mail automatically.
>

Re: Script to Email attachment hangs on the AddAttachment statemen by Pegasus

Pegasus
Fri May 02 16:09:07 CDT 2008

I think you should do some trouble-shooting by process of elimination.
We already know that the script sample I gave you works. We also
think that your machine works. This leaves your network and your
Internet connection. I would now run the sample script on two different
machines:
a) On a machine at a different location, e.g. your home PC.
b) On a different machine connected to the same network.


"Chris" <chris@discussions.microsoft.com> wrote in message
news:1AB368E9-5E4A-434F-BD2B-8997C75BD510@microsoft.com...
>I tried rebooting in Safe Mode with Networking and still have the same
>problem.
>
> Any other suggestions?
>
> Thanks,
> Chris
>
> --
> No matter where you go, there you are...
>
>
> "Pegasus (MVP)" wrote:
>
>> I would now reboot the machine in "Safe Mode with Networking"
>> and try again.
>>
>>
>> "Chris" <chris@discussions.microsoft.com> wrote in message
>> news:4F59A03A-24A5-4690-B782-00A4E7AE9212@microsoft.com...
>> > 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
>> >
>>
>>
>>



Re: Script to Email attachment hangs on the AddAttachment statemen by chris

chris
Fri May 02 16:21:02 CDT 2008

It works fine on other machines on this network as well as other machines on
other networks.

Thanks,
Chris

--
No matter where you go, there you are...


"Pegasus (MVP)" wrote:

> I think you should do some trouble-shooting by process of elimination.
> We already know that the script sample I gave you works. We also
> think that your machine works. This leaves your network and your
> Internet connection. I would now run the sample script on two different
> machines:
> a) On a machine at a different location, e.g. your home PC.
> b) On a different machine connected to the same network.
>
>
> "Chris" <chris@discussions.microsoft.com> wrote in message
> news:1AB368E9-5E4A-434F-BD2B-8997C75BD510@microsoft.com...
> >I tried rebooting in Safe Mode with Networking and still have the same
> >problem.
> >
> > Any other suggestions?
> >
> > Thanks,
> > Chris
> >
> > --
> > No matter where you go, there you are...
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >> I would now reboot the machine in "Safe Mode with Networking"
> >> and try again.
> >>
> >>
> >> "Chris" <chris@discussions.microsoft.com> wrote in message
> >> news:4F59A03A-24A5-4690-B782-00A4E7AE9212@microsoft.com...
> >> > 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
> >> >
> >>
> >>
> >>
>
>
>