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:
-
Add a code step to your workflow with the code below.
- Click “Refresh fields”.
- In the “Configure” section, select your Gmail account.
- 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;
},
});