Edits history of script submission #214 for ' Send Email Single Recipient (sendgrid)'

  • deno
    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> = { to, from, subject };
      messageObject[is_message_html ? "html" : "text"] = message;
    
      try {
        return await sendgrid.send(messageObject);
      } catch (error) {
        throw Error("\n" + JSON.stringify(error?.response?.body || error));
      }
    }
    

    Submitted by hugo697 395 days ago

  • deno
    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> = { to, from, subject };
      messageObject[is_message_html ? "html" : "text"] = message;
    
      try {
        return await sendgrid.send(messageObject);
      } catch (error) {
        throw Error("\n" + JSON.stringify(error?.response?.body || error));
      }
    }
    

    Submitted by admin 1028 days ago

  • deno
    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> = { to, from, subject }
      messageObject[is_message_html ? 'html' : 'text'] = message
    
      try {
        return await sendgrid.send(messageObject)
      } catch (error) {
        throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
      }
    }
    

    Submitted by admin 1031 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/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> = { to, from, subject }
      messageObject[is_message_html ? 'html' : 'text'] = message
    
      try {
        return await sendgrid.send(messageObject)
      } catch (error) {
        throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
      }
    }
    

    Submitted by adam186 1159 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/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> = { to, from, subject }
      messageObject[is_message_html ? 'html' : 'text'] = message
    
      try {
        return await sendgrid.send(messageObject)
      } catch (error) {
        throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
      }
    }
    

    Submitted by adam186 1194 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/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> = { to, from, subject }
      messageObject[is_message_html ? 'html' : 'text'] = message
    
      try {
        return await sendgrid.send(messageObject)
      } catch (error) {
        throw Error('\n' + (JSON.stringify(error?.response?.body || error)))
      }
    }
    

    Submitted by adam186 1282 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/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> = { to, from, subject }
      messageObject[is_message_html ? 'html' : 'text'] = message
    
      try {
        return await sendgrid.send(messageObject)
      } catch (error) {
        throw Error('\n' + JSON.stringify(error?.response?.body || error))
      }
    }
    

    Submitted by adam186 1283 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    import sendgrid from "npm:@sendgrid/mail@^7.7.0"
    
    /** 
     * @param isMessageHtml 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> = { to, from, subject }
      messageObject[is_message_html ? 'html' : 'text'] = message
    
      try {
        return await sendgrid.send(messageObject)
      } catch (error) {
        throw Error('\n' + JSON.stringify(error?.response?.body || error))
      }
    }
    

    Submitted by adam186 1283 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    import sendgrid from "npm:@sendgrid/mail@^7.7.0"
    
    /** 
     * @param isMessageHtml 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,
      isMessageHtml: boolean
    ) {
      sendgrid.setApiKey(api_token.token);
      const messageObject: Record<string, string> = { to, from, subject }
      messageObject[isMessageHtml ? 'html' : 'text'] = message
    
      try {
        return await sendgrid.send(messageObject)
      } catch (error) {
        throw Error('\n' + JSON.stringify(error?.response?.body || error))
      }
    }
    

    Submitted by adam186 1284 days ago