Upload an attachment



Sub Attachment_Load(Debug,  CurrentTestSet,  CurrentTest,  CurrentRun)
' Workflow script
    On  Error  Resume  Next
    Set  BugFact  =  TDConnection.BugFactory
    Set  theBug  =  BugFact.Item(21)
    Set  AttachFact  =  theBug.Attachments
    Set  theAttachmentsCollection  =  AttachFact.NewList("")
    Set  theAttachment  =  theAttachmentsCollection.Item(1)

    'This  works  in  VB,  but  not  in  VBScript:
    'theAttachment.Load  True,  LoadPath
    'In  VBScript,  use  this:
    theAttachment.Load  True,  ""
    tdoutput.Print  theAttachment.FileName

    '  To  get  the  path  in  VBScript,  extract  it  from
    '  the  filename:
    theFileName  =  theAttachment.FileName
    tdoutput.Print  theFileName
    thePath  =  Left(theFileName,  InstrRev(theFileName,  "\")-1)
    tdoutput.Print  thePath

    '  handle  run-time  errors
    If  Err.Number  <>  0  Then
        TDOutput.Print  "Run-time  error  ["  &  Err.Number  &  "]  :  "  &  Err.Description

        '  update  execution  status  in  "Test"  mode
        If  Not  Debug  Then
            CurrentRun.Status  =  "Failed"
            CurrentTest.Status  =  "Failed"
        End  If
    End  If
End  Sub