import sendgrid from "npm:@sendgrid/mail@^7.7.0";
/**
* @param is_message_html If `true` then the message will be sent and parsed as HTML,
* otherwise it will be sent as plain text.
*/
type Sendgrid = {
token: string;
};
export async function main(
api_token: Sendgrid,
from: string,
to: string[],
subject: string,
message: string,
is_message_html: boolean,
) {
sendgrid.setApiKey(api_token.token);
const messageObject: Record<string, string | string[]> = {
to,
from,
subject,
};
messageObject[is_message_html ? "html" : "text"] = message;
try {
return await sendgrid.send(messageObject, true);
} catch (error) {
throw Error("\n" + JSON.stringify(error?.response?.body || error));
}
}
Submitted by admin 497 days ago
import sendgrid from "npm:@sendgrid/mail@^7.7.0"
/**
* @param is_message_html If `true` then the message will be sent and parsed as HTML,
* otherwise it will be sent as plain text.
*/
type Sendgrid = {
token: string;
};
export async function main(
api_token: Sendgrid,
from: string,
to: string[],
subject: string,
message: string,
is_message_html: boolean
) {
sendgrid.setApiKey(api_token.token);
const messageObject: Record<string, string | string[]> = {
to,
from,
subject
}
messageObject[is_message_html ? 'html' : 'text'] = message
try {
return await sendgrid.send(messageObject, true)
} catch (error) {
throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
}
}
Submitted by admin 500 days ago
import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts"
import sendgrid from "npm:@sendgrid/mail@^7.7.0"
/**
* @param is_message_html If `true` then the message will be sent and parsed as HTML,
* otherwise it will be sent as plain text.
*/
export async function main(
api_token: wmill.Resource<"sendgrid">,
from: string,
to: string[],
subject: string,
message: string,
is_message_html: boolean
) {
sendgrid.setApiKey(api_token.token);
const messageObject: Record<string, string | string[]> = {
to,
from,
subject
}
messageObject[is_message_html ? 'html' : 'text'] = message
try {
return await sendgrid.send(messageObject, true)
} catch (error) {
throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
}
}
Submitted by adam186 628 days ago
import * as wmill from "https://deno.land/x/windmill@v1.70.1/mod.ts"
import sendgrid from "npm:@sendgrid/mail@^7.7.0"
/**
* @param is_message_html If `true` then the message will be sent and parsed as HTML,
* otherwise it will be sent as plain text.
*/
export async function main(
api_token: wmill.Resource<"sendgrid">,
from: string,
to: string[],
subject: string,
message: string,
is_message_html: boolean
) {
sendgrid.setApiKey(api_token.token);
const messageObject: Record<string, string | string[]> = {
to,
from,
subject
}
messageObject[is_message_html ? 'html' : 'text'] = message
try {
return await sendgrid.send(messageObject, true)
} catch (error) {
throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
}
}
Submitted by adam186 663 days ago
import * as wmill from "https://deno.land/x/windmill@v1.51.0/mod.ts"
import sendgrid from "npm:@sendgrid/mail@^7.7.0"
/**
* @param is_message_html If `true` then the message will be sent and parsed as HTML,
* otherwise it will be sent as plain text.
*/
export async function main(
api_token: wmill.Resource<"sendgrid">,
from: string,
to: string[],
subject: string,
message: string,
is_message_html: boolean
) {
sendgrid.setApiKey(api_token.token);
const messageObject: Record<string, string | string[]> = {
to,
from,
subject
}
messageObject[is_message_html ? 'html' : 'text'] = message
try {
return await sendgrid.send(messageObject, true)
} catch (error) {
throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
}
}
Submitted by adam186 751 days ago
import * as wmill from "https://deno.land/x/windmill@v1.51.0/mod.ts"
import sendgrid from "npm:@sendgrid/mail@^7.7.0"
/**
* @param is_message_html If `true` then the message will be sent and parsed as HTML,
* otherwise it will be sent as plain text.
*/
export async function main(
api_token: wmill.Resource<"sendgrid">,
from: string,
to: string[],
subject: string,
message: string,
is_message_html: boolean
) {
sendgrid.setApiKey(api_token.token);
const messageObject: Record<string, string | string[]> = {
to,
from,
subject
}
messageObject[is_message_html ? 'html' : 'text'] = message
try {
return await sendgrid.send(messageObject, true)
} catch (error) {
throw Error('\n' + JSON.stringify(error?.response?.body || error))
}
}
Submitted by adam186 752 days ago