Is it Possible to Change the "From" Email in Pipedream's Gmail Component Like in Zapier?

This topic was automatically generated from Slack. You can find the original thread here.

In the gmail component I can’t see a way to change the “from” email. You can only change the “from” name.
Other automation software like Zapier does give that option, letting you send emails via gmail from any alias that is available in the gmail account.
Am I missing something or is it just not available in pipedream right now?
Any workarounds?

Hi . Unfortunately, Pipedream’s Gmail Send Email action currently doesn’t support sending emails from an alias in your gmail account. As a workaround, you could create a custom Node.js code step that sends an email like the Send Email action does, but also has a From field:

  1. Add a code step to your workflow with the code below.
  2. Click “Refresh fields”.
  3. In the “Configure” section, select your Gmail account.
  4. Select the From field from the “Optional Fields” and enter your alias, e.g. My Name <[myalias@gmail.com](mailto:myalias@gmail.com)>.
import gmail from "@pipedream/gmail"

export default defineComponent({
  description: "Send an email from your Google Workspace email account, optionally as an alias",
  props: {
    gmail,
    to: {
      propDefinition: [
        gmail,
        "to",
      ],
    },
    cc: {
      propDefinition: [
        gmail,
        "cc",
      ],
    },
    bcc: {
      propDefinition: [
        gmail,
        "bcc",
      ],
    },
    fromName: {
      propDefinition: [
        gmail,
        "fromName",
      ],
    },
    from: {
      type: "string",
      optional: true,
      label: "From",
      description: "Specify the send-as address or alias for the email. Defaults to your account's name and email address.",
    },
    replyTo: {
      propDefinition: [
        gmail,
        "replyTo",
      ],
    },
    subject: {
      propDefinition: [
        gmail,
        "subject",
      ],
    },
    body: {
      propDefinition: [
        gmail,
        "body",
      ],
    },
    bodyType: {
      propDefinition: [
        gmail,
        "bodyType",
      ],
    },
    attachments: {
      propDefinition: [
        gmail,
        "attachments",
      ],
    },
    inReplyTo: {
      propDefinition: [
        gmail,
        "inReplyTo",
      ],
    },
    mimeType: {
      propDefinition: [
        gmail,
        "mimeType",
      ],
    },
  },
  async run({ $ }) {
    const opts = await this.gmail.getOptionsToSendEmail($, this);
    // Set the send-as address or alias
    if (this.from) opts.from = this.from;
    const response = await this.gmail.sendEmail(opts);
    $.export("$summary", `Successfully sent email to ${[this.to](http://this.to)}`);
    return response;
  },
});

Amazing! Thankyou!! I’ll give it a try