for image attachment
nlapiAttachRecord(‘file’, checkImageId, ‘salesorder’, SOId);
checkImageId is ther internalid of the image in the file cabinet

if we want to add a email on ‘message’ on communication tab
var records = new Object();
records[‘transaction’] = SOId;
var emailSend = nlapiSendEmail(senderEmailToUse, setby, emailSubject, emailBody,null,null,records);
here we need SOId is sales order internal id
