In my case I have a drop-down list of files with preloaded filenames to attach. Here is the code that works for me on a click of button.
var selectFileName = form1.subform.DropDownList1.rawValue;
if (selectFileName != "Please Select") {
var doc = event.target;
doc.importDataObject(selectFileName);
var MyPar1 = doc.getDataObject(selectFileName);
var filename = MyPar1.path;
}
After you click the button it open a windows dialog box asking you to choose the file and adds the attachment to the attachment pane in runtime. To view the attachments simply view the attachment pane in runtime after you add the attachments.
Good luck,
SekharN