#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2015
    Posts
    1
    Rep Power
    0

    Problem getting filename and path into CDO message


    My attached script is designed to send an email whenever a file appears in a server folder; the subject is set to the filename and the body includes the file path. The received email has blank subject and no filepath. Does anyone know why? Thank you

    Code:
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = WScript.CreateObject("WScript.Shell")
    strRejectionsSourceFolder = "\\iseries\myfolder\"
    strRejectionsEmail="me@server.com"
    
    'Cycle through any files in the source folder
    For Each sFile In objFSO.GetFolder(strRejectionsSourceFolder).Files
    if left(sFile.Name,3)="REJ" then	
    	'Prepare an email to notify someone of the rejection
    	Set myMail=CreateObject("CDO.Message")
    	myMail.Subject=sFile.Name
    	myMail.From=strRejectionsEmail
    	myMail.To=strRejectionsEmail
    	myMail.TextBody="A file has been rejected:"
    	myMail.TextBody= myMail.TextBody & vbcrlf & sfile.path
    ...set config fields and send...
    end if
    Next
  2. #2
  3. No Profile Picture
    Aged to perfection.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    487
    Rep Power
    509
    [NEW USERS] - How to post a question.

    Please read that and reply with the exact language and use the code tags which will color code the code making it easier to read.
    Last edited by Brendan.C; February 18th, 2017 at 03:05 AM.

IMN logo majestic logo threadwatch logo seochat tools logo