Is there any way to send out emails via script page?

  • 0
  • 1
  • Question
  • Updated 5 months ago
  • In Progress
Does anyone know if there is any way to send out emails via script page?

How about using: require 'gmail_sender'
and adding your gmail user and password etc?

Thanks
Photo of Micro Dev

Micro Dev

  • 834 Points 500 badge 2x thumb

Posted 6 months ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,522 Points 20k badge 2x thumb
Try this code:

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=660

Notes:

(1) The function takes arguments email, subject and message and returns a promise which resolves when the email has been sent via the native method UserWin:
function QBU_SendEmail(email, subject, message) {...}
(2) You use the function in this fashion:
var email = "dandiebolt@gmail.com";
var subject = "Subject";
var message = "<h1>Hello ${firstName} ${lastName}</h1><p>Did you file your TPS Reports?</p>";
QBU_SendEmail(email, subject, message)
  .then(function() {
    //your further code here
  });
(3) The native UserWin method requires the userid (eg "51084879.bdbt") which is obtained by passing the user's email to API_GetUserInfo.

(4) The message is passed as a very short template which can include references to tokens for the firstName and lastName. The message can also include HTML markup.

(5) If you intent to do bulk emails you can't just wrap a loop around this code as your browser will process the code as fast as possible and will eventually run out of sockets at which time the browser will lock up. One solution it to wrap the code in an async function.
(Edited)
Photo of Micro Dev

Micro Dev

  • 834 Points 500 badge 2x thumb
Thanks Dan. To clarify this will send it via quickbase and from address will be notify@quickbase.com and the reply to will be the users email address. I was looking to sent it via gmail user and password. But if that's not possible, this solution will definitely be helpful.

Thanks again.