-1

I have an google web app that uses the send mail function, it works but when users use it, emails are sent automatically from my account, I want to know if there is a possibility that emails are sent from the account who uses the app.

I initially deployed the application by setting it :

  • Execute the app as : Me (my account)
  • Who has access to the app : Any member of company domain

I later reconfigured the application as follows

  • Execute the app as : User accessing the web app
  • Who has access to the app : Any member of company domain

Other permissions were then requested to users, everyone naturally accepted, but the application blocks.

zanzibar
  • 45
  • 1
  • 7

2 Answers2

0

This definitely should be possible, because there are lots of applications like Outreach.io, Hubspot, Autopilot, and FrontApp that have users connect their G Suite account in order to use that infrastructure for sending.

  1. Can you further explain what you mean by "the application blocks"?
  2. What happened regarding the email send once you made the changes to send from the User accessing the Web App? Was there no change or did it throw an error?
  3. Do you have a copy of the email in your G Suite or Gmail inbox that was sent via the Web App? If so can you go to "Show Original" and copy paste the header information into this thread? This info will allow me to quickly assess a little more information about the sending infrastructure. Be aware that the "Show Original" information cannot be from a forwarded email.

Peace, -LB

  • Thank you very much LoriBeth, I am not at work at this moment, I will give you much more detail as soon as I join the work in the day. – zanzibar Apr 01 '19 at 22:51
  • I thank you very much for your intervention LoriBeth, you were right, I put the entire script online, it can be useful for others, – zanzibar Apr 03 '19 at 17:52
0

There was an unused library that was hanging in the project, also the fact that I could not empty the some manifest file,

So I deleted the entire project from the cloud, and I redid the script again, being very careful about everything I did,

Finally I shared the application, and users were finally able to send emails, which were sent from their own accounts,

I thank you very much for your intervention, you were right, I put the entire script online, it can be useful for others,

I just specify that the script pick data from the sheet, puts it in a table, and adds a signature with animated gif images,

function sendemail(id) {
  var rw = parseInt(id);
 var agent = Session.getActiveUser().getEmail();
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Saisie");
  var des = sheet.getRange(rw,8).getValue();
  var eml = sheet.getRange(rw,9).getValue();
  var dat = Utilities.formatDate(new Date(), "Europe/Paris", "dd/MM/yyyy");
  var typ = sheet.getRange(rw,5).getValue();
  var nbo = sheet.getRange(rw,6).getValue();
  var obj = sheet.getRange(rw,7).getValue();
  var num = sheet.getRange(rw,4).getValue();
  var soc = sheet.getRange(rw,11).getValue();
  var nom = sheet.getRange(rw,12).getValue();
  var adr = sheet.getRange(rw,13).getValue();
  var vil = sheet.getRange(rw,14).getValue();
  var pay = sheet.getRange(rw,15).getValue();
  var company = DriveApp.getFileById('abcd').getBlob().setName("company");
  var departement = DriveApp.getFileById('abcd').getBlob().setName("company");
  var userName = getUserInfo(agent);
  var msg = '<html><head><meta charset="utf-8">' +
  '<style>table{border-collapse:collapse;}td{border: 1px solid black;padding-left:4px;}.tete{background-color:#f6f6f6;text-align:center;}.titre {background-color:#ebffce;}</style>' +
  '</head><body>Bonjour,<br><br><table style="width:100%;"><tr><td colspan="2" class="tete">Réception d&apos;objet à l&apos;attention de « <span style="color:#0900c6;">'+ des + '</span> »</td></tr>' +
  '<tr><td width="140" width class="titre">Date de réception</td><td>'+ dat +'</td></tr>' +
  '<tr><td class="titre">Objet & Nombre</td><td>'+ obj + ' - ' + nbo + '</td></tr>' +
 '<tr><td class="titre">Type Transport</td><td>'+ typ + '</td></tr>' +
  '<tr><td class="titre">N° Transport</td><td>'+ num +'</td></tr>' +
  '<tr><td colspan="2" class="tete">Info Expéditeur</td></tr>' +
  '<tr><td class="titre">Société</td><td>'+ soc +'</td></tr>' +
  '<tr><td class="titre">Collaborateur</td><td>'+ nom +'</td></tr>' +
  '<tr><td class="titre">Adresse</td><td>'+ adr +'</td></tr>' +
  '<tr><td class="titre">Ville - Pays</td><td>'+ vil + ' ' + pay + '</td></tr></table><br>' +
  'Cordialement, '+ userName +' - Service Courrier.<br><br>' +
  '<table style="border-collapse:collapse;"><tr>' +
  '<td rowspan="2" style="text-align:center;border: 1px solid black;"><img src="cid:logocompany"></td>' +
  '<td  style="text-align:center;border: 1px solid black;"><img src="cid:logodepartement"></td>' +
  '</tr><tr><td style="text-align:center;border: 1px solid black;padding:4px;"><div style="text-align:center;">' +
  '12 Place de la République - 75123 Paris Cedex 10<br>Tél. : 02 44 44 44 44  -  Fax : 02 55 55 55 55<br>Email : <a href="mailto:'+agent+'">'+agent+'</a></div></td></tr></table></body></html>';
  MailApp.sendEmail({
    to: eml,
    subject: "Message Automatique Service Courrier",
    htmlBody: msg,
    inlineImages:{
      logocompany: company,
      logodepartement:departement
    }
  });
}
zanzibar
  • 45
  • 1
  • 7