Advertisement

05.29.2008 at 02:54PM PDT, ID: 23443107
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.7

VBS script won't work when behind network

Asked by kuney in Simple Mail Transfer Protocol (SMTP), VB Script

Tags:

I have written a little vbs file that monitors a directory and if a file has been in that directory for over 4 hours it moves it to another directory and then emails.  This works perfectly fine at my home behind my cable modem and router on a windows xp pro machine.  Here is the code

Option Explicit

On Error Resume Next

Dim fso, FileSet, Path, File, DDiff, Date1, Date2, DestPath, objEmail

Do

      Path = "C:\test"                                                'Directory that the script is monitoring
      DestPath = "C:\TestArchive\"                              'Directory that a file will get moved to

      FileSet = GetDirContents(Path)                              'Call the GetDirContents Function

            For each File in FileSet
                  Set File = fso.GetFile(Path & "\" & File)
                        Date1 = File.DateLastModified
                  'date is in 24 hours spands, so if you want days i day is 24
                        Date2 = Now()

                        DDiff = Abs(DateDiff("h", Date1, Date2))

            If DDiff >= 4 Then
                  If Not fso.FileExists(DestPath & File.Name) Then
                        File.Move DestPath
                  Set objEmail = CreateObject("CDO.Message")
                        objEmail.From = "sender@emaildomain.com"                        'Put your own from email address
                        objEmail.To = "receiver@emaildomain.com"                  'Put your own email to address
                        objEmail.Subject = "Email Subject"                        'Email subject line
                        objEmail.Textbody = "File, [" & File.Name & "], has been moved to the Import_Archive directory"                  'What you want the email to say
                        objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                        objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domain.net"            'change to your own smtp
                        objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
                        objEmail.Configuration.Fields.Update
                        objEmail.Send
'wscript.echo "Finished [" & File.Name & "] Now"                  'This was just for testing purposes
'wscript.echo File.Name                                          'This was just for testing purposes
                  Else
                  wscript.echo "Unable to move file [" & File.Name & "]. A file by this name already exists in the target directory."
                  End If
            End If
      Next
'wscript.echo "Finished [" & File.Name & "] Now"

      Wscript.Sleep 60000                        'Pause for 10 minutes                  
Loop                                                      'Loop back up to the Do statement and start over after the 10 minute pause

Function GetDirContents(FolderPath)

Dim FileCollection, aTmp(), i

      Set fso = CreateObject("Scripting.FileSystemObject")
            Set FileCollection = fso.GetFolder(FolderPath).Files

            Redim aTmp(FileCollection.count - 1)
                  i = -1

            For Each File in FileCollection
                  i = i + 1
                  aTmp(i) = File.Name
            Next

      GetDirContents = aTmp
End Function


If I use this same code behind a network and put in their smtp server mail.thierdomain.org it doesn't work. (it will move the files but never emails)  This is on a 2003 server when on the network.  I know the smtp server is correct for this network, but what could be my other problems?  thanks.Start Free Trial
 
Loading Advertisement...
 
[+][-]05.29.2008 at 03:09PM PDT, ID: 21673752

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 03:12PM PDT, ID: 21673771

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 03:15PM PDT, ID: 21673796

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 03:22PM PDT, ID: 21673850

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 03:31PM PDT, ID: 21673892

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 03:46PM PDT, ID: 21673956

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 03:57PM PDT, ID: 21674015

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 04:04PM PDT, ID: 21674052

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 04:11PM PDT, ID: 21674082

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Simple Mail Transfer Protocol (SMTP), VB Script
Tags: VBScript
Sign Up Now!
Solution Provided By: purplepomegranite
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.29.2008 at 04:20PM PDT, ID: 21674129

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 05:15PM PDT, ID: 21674377

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 05:51PM PDT, ID: 21674503

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 07:07PM PDT, ID: 21674764

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628