title: Google Script Error: You do not have permission to call openById
body: <p>I am trying to send a mail with attaching a file available in my google drive using following google scripts</p>
  
  <pre><code>var file=DriveApp.getFileById('1qZVK0UZ1jLbDdj10FXZqeAVEodvxEy2Bs');
  MailApp.sendEmail('xyz@gmail.com','subject','body',{attachments[file.getAs(MimeType.PDF)]});
  </code></pre>
  
  <p>when I run above script manually it runs fine, email gets sent. But when I run it using form Submission trigger it gives error "You do not have permission to call openById"</p>
  
  <p>steps that will reproduce the problem?</p>
  
  <ol>
  <li>create a google form.</li>
  <li>write above scripts on script editor and add a trigger with submission of the form.</li>
  <li>fill and submit the form then you will get above error into mail from 'apps-scripts-notifications@google.com'</li>
  </ol>
  
  <p>Please help.</p>