Q:

Attach a CSV in Mail

I want to attach a csv file in mail(grails)
The file in the path is already present. I am using the following code
sendMail {
    multipart true
    from "$senderName <$fromAddress>"
    to toAddress
    cc message.cc
    subject message.subject
    body content.plaintext
    html content.html
    attachBytes './web-app/ReadyOrdersFor-${vendor.name}','text/csv', new File('./web-app/ReadyOrdersFor-${vendor.name}').readBytes()
}

Error prompted is.
java.io.FileNotFoundException: ./web-app/ReadyOrdersFor-${vendor.name}.csv (No such file or directory)

neither this works prompting the same error
attachBytes './web-app/ReadyOrdersFor-${vendor.name}.csv','text/csv', new File('./web-app/ReadyOrdersFor-${vendor.name}.csv').readBytes()

A:

The issue is that you trying you use the file path string as a GStringImpl, but the string is enclosed in single quotes. GStringImpl is natively supported in groovy in double quotes.
You code should be  
attachBytes "./web-app/ReadyOrdersFor-${vendor.name}",'text/csv', new File("./web-app/ReadyOrdersFor-${vendor.name}").readBytes()

This link should help you understand the difference between using single and double quotes in groovy.

