Any workaround for the 10 recipients limitation in...
# suitescript
w
Any workaround for the 10 recipients limitation in email.send()? (Except sending individual emails) I need to send out a shit-list to people not approving in time and would like to bcc all in a single email. In SS1 it looks like you were allowed to send one email to more recipients if you set notifySenderOnBounce to false. That setting appear to make it a bulk-email, but the email.sendBulk() seems to have the same 10 recipient limitation. I don't see that option in SS2.
s
if you ask me, best easiest you set a bcc to a distribution list. i'm also stuck at 10.
w
Yeah, but I only want to email the users that are on the shit-list. So I can't have a static distribution list.
s
not suggesting but send individual emails with the shit list included in the body? i'm sorry maybe filtered by a uniqueArr to only send it once?
c
10 is a hard limit w/ scripting the email send. You may have to generate a list of emails and email that list to yourself and then copy/paste those emails into an outside email app and send that way. Otherwise you'll have to do chunks of 10 which you don't want.
w
yeah, that is the other way to do it. I have the list on in the body. But then I need to send out 2-300 individual emails at 20 governance units a pop
...so just under 500 emails (including query and render) in a scheduled script. I could of course do it in a MR, but I thought it would be nice and small in a short scheduled script
I just tried to use email.sendBulk() but with bogus emails in bcc "watz+1@mydomain.com","watz+2@mydomain.com". I had more than 10 in the list. No errors were thrown, but I only received one email to the "recipient" which was my own employee internal id.
c
if you're doing that in sandbox it makes sense
πŸ’― 1
w
Nope, production debugger.
Does the debugger have the same restriction?
s
@Watz are you using debugger as a scratchpad or actually on a deployed script?
w
scratchpad
It doesn't seem to be any limitation on sending emails in prod debugger. Just sent to my personal e-mail without issues. I guess it's smart enough to see through my "+" aliasing. Now I just need 10+ emails to test with πŸ˜‚
@creece have you tried with sendBulk?
It would have been so neat (excluding the actual template and query)!
Copy code
const queryResults = query.runSuiteQL({
		query: mainQuery
	}).asMappedResults()
	
	const emails = query.runSuiteQL({
		query: `SELECT DISTINCT assigned_to_email FROM ${mainQuery}`
	}).asMappedResults()

	const renderer = render.create()

	renderer.templateContent = template
	renderer.addCustomDataSource({
		format: render.DataSource.OBJECT,
		alias: 'data',
		data: {
			rows: queryResults
		}
	})

	const body = renderer.renderAsString()
	
	email.sendBulk({
		author: 1,
		body,
		recipients: 1,
		subject: 'test reminder',
		bcc: emails.map(email => email.assigned_to_email),
	})
s
I actually believe it’s an error in the documentation. We have been using sendBulk for over 10 recipients, and it has been working. We use the following code to switch automatically as needed:
πŸ’― 1
w
email.send() will give me an error when I have more than 10 emails in the bcc-list. email.sendBulk() does not. But I can't verify that all would arrive since I would need to send out to more than 10 real emails.
@scottvonduhn awesome!
s
SuiteAnswers frequently disappoints me with incorrect information
w
Support Case on the way! πŸ˜„
s
I suppose an alternate solution that preserves bounce notification would be to break the recipient list into groups of 10 and send each group separately, if the bounce back is important.
w
Not really in this case. Do you know if it still logs it under each employee/contact when you use sendBulk()?
s
we use this for sending to customer contacts, so not sure how it logs when sending to employee records
so long as you use the id of the employee, rather than the actual email address, it should associate them automatically
w
If I recall correctly, as long as you use the internal id of the contact, it would attatch it
yeah, exactly
s
Yeah, it works that way for contacts, seems reasonable it would for employees too.
But then, this is NetSuite
πŸ˜† 1