new char[] here creates a memory leak. In general, there's no need for copying the data around so much. A simpler version is just:

attachments[i].body.resize(file.size());
file.read(attachments[i].body.data(),file.size());