Split Draft up by each line

Looking to create an action that would take each line and send it as its own email in the background… Each email would be going to the same place. The idea is I take a bulleted list of todos and send them to our ticketing system as separate emails so they get created as separate tickets. Any ideas? Thanks in advance

You could start with TADpoLe a great Drafts library. That would give you the examples how to split.

May I ask which ticket system you want to feed?
That would help with the matter.

Greg published an example script for simple emailing with mailto

If you only send text that might be what you want.

Feel free to ask me more if you hit a blocker

Not tested, but I think something like this should work.

Prerequisite.
Uses TADpoLe. Install the ThoughtAsylum action group and includ the TAD action at the start of your action to include the library.

function mailer(p_strMail)
{
	let mail = Mail.create();
	mail.toRecipients = ["test@mail.com"];
	mail.subject = p_strMail;
	mail.body = p_strMail;

	if (mail.send()) return true;
	else
	{
		console.log(mail.status);
		return false;
	}
}

draft.TA_processLinesFunctionRetain(mailer);

Hope that helps.

2 Likes

Maybe it would be nice to add two counters one for success and one for failed messages. Then you can verify that everything went well.

(error counter == 0 or success counter == todo items)