How to send email from delegated account using Gmail API - gmail-api

I have created an automated google script to send notification email on periodic basis but I want mail to be send from my delegated account since I logged in using my primary email, so I can't send it through my delegated email account.
I tried to achieve the same using send email as functionality but it is not working, recipients are receiving mails from my primary address.
Please provide your inputs
Thanks

First you need to add the delegated account in your usual inbox. Go to:
Settings>Accounts>Send mail as:>add another email address
Make sure that the "Treat as alias" checkbox is checked; submit and verify the request.
Second, you can access all the aliases with GmailApp.getAliases().
Finally, you are able to choose the alias with the Gmail Draft or Message Services by changing the from field in the option object.
https://developers.google.com/apps-script/reference/gmail/gmail-draft#update(String,String,String,Object)

Related

azure logic app not able to retrieve who is the approver after approving the mail(UserEmailAddress- showing Null)

I have created a flow using logic apps where once the owner approves the mail I need to know who approved that mail. While using normal my account I am able to retrieve the user who approved the mail but while using the service account am not able to retrieve the values. All the values its showing as null while using the service account.
How do I get the --> email address <-- of the user that selects 'Approve' or 'Reject' buttons in the email? If an email is forwarded to another person I would like to know who (email address) clicked approve or reject.
After reproducing from my end, I observed that when the mail is viewed in HTML format this doesn't work and also while forwarding the mail, but this works when the response is sent through the adaptive cards and not the HTML message that are received during the Send email with options action. One way that this can work is when you use only the adaptive cards that are send as the request.
RESULTS:
and when you use HTML responses then below is something how you'll be receiving the response.
You can also try Creating your own actionable messages for Flow Approvals by StefanS365 where in you add provider in Actionable Email Developer Dashboard and request the approvals.

Is it possible to specify a from email address when inviting users to AAD using Application permission User.Invite.All

I have an application leveraging the Microsoft Graph SDK for C# and I have registered that application to use the Application Permission User.Invite.All. I would like to specify the email address the invitation should come from.
Is that possible?
You can't set the address if you use the default invitation email.
If you want a custom sender address, you'll need to send the invite email yourself through some email provider.
You can disable the default email send with:
"sendInvitationMessage": false
In the response, you will get inviteRedeemUrl.
This is the link you need to send to the user so they can accept the invite.

Azure AD B2C Custom Policy Verification Email Customisation

I have set up a custom Password Reset policy in Azure AD B2C that allows the user to change their password while displaying custom branding elements depending on specific scenarios. This policy contains a step where the user verifies their Email Address by entering a verification code that is sent to their inbox.
From this post in the Microsoft Azure Feedback Forums: fully-customizable-verification-emails
It seems it is not possible to fully customise verification emails.
However, is it possible to perform some basic customisation of the verification e-mail within a custom policy? (text sent in the "From" and "Title" sections of the email and modifications to the text sent in the body).
Currently, you aren't able to customize the email messages, but -- as you have found on the feedback forum -- this is being considered by the product team.
You can customise the verification emails by using a 3rd party email service to send the emails.
For example, we have Azure AD B2C configured to send emails with SendGrid. We then use SendGrid templates to customise the contents of the email. This involves using Custom Policies, so it's definitely an advanced use case.
Once set up, you can create and use any SendGrid email template, and use the {{otp}} and {{email}} parameters in the body of the email, which will be replaced dynamically with the one-time password value and the user email address.
The instructions to send emails with SendGrid are here: https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-email-sendgrid?pivots=b2c-custom-policy
For Mailjet, the instructions are here: https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-email-mailjet?pivots=b2c-custom-policy

GMail API - Can I send email using the Service Account?

When I send an email using the GMail API, I get an Access Token for the user to whom the message is to be sent and then when sending the message, I put some value in the From Field.
But no matter what I put in the from field, the message in the email shows as From "Me" and is in the Sent mails as well as Inbox.
Is there a way, I could use the Service Account to send the email, so that it does not show up as From "Me" and is also not in the Sent Mails.
You cannot use a service account to impersonate a free gmail account. I spent a lot of time confirming this after reading a reply that was here before. Maybe it worked at some point, but it doesn't anymore.
There is no way to share / grant another user permission to access
your standard gmail account. So there is no way for you go delegate
the permissions for bob#mycompany.com to access bob#gmail.com.
and
you can impersonate G-Suite accounts but not Gmail accounts
These quotes are from Google's official C# Auth repo:
https://github.com/googleapis/google-api-dotnet-client/issues/1561
No. The Gmail API is for Gmail users and service accounts are just for doing auth to a real Gmail account, they don't have their own Gmail account, etc.
If you want to send the email from some service, you need some bulk-sending email service like at: https://cloud.google.com/compute/docs/tutorials/sending-mail/ or something you run yourself or from some other provider.
No, what you are looking for is a bulk email sending service. Checkout sendgrid , Amazon AWS SES, mandrill or if you want to stick with Google, this. You could of course run your own postfix server (although I'm assuming you were using gmail api for deliverability in the first place.

How to forward emails from Google Apps (Gmail) to Sendgrid?

I am trying to use Sendgrid as SMTP server for sending all emails from my users using Google Apps for email.
The catch is that Sendgrid requires password authentication and i couldn't find a way in Google apps Admin console to out that in (theough of coruse, there are ways to enter the SMTP server IP, but it doesn't work).
How to hook SendGrid to Free Gmail account (Not Google for work account)?
See: https://support.google.com/mail/answer/22370?hl=en
Click the gear in the top right.
Select Settings.
Click the Accounts and Import tab.
Under Send mail as, click Add another email address.
Click Add account >>
Give a descriptive name to this new "email transmitter" (e.g. "Send mails via SendGrid")
Give any email address that belong to you but not a GMAIL email (e.g myemail#mydomain.com)
Uncheck the Alias check mark
Change your SMTP to smtp.sendgrid.net
Use ports 587 for plain/TLS connections .
SendGrid username (sendgridname)
SendGrid password (sendgridpassword)
Gmail will send you a verification email to the "transmitter email" (e.g to myemail#mydomain.com)
Open your other account (mantas.hof.hefer#hhcc.org.il) and either click the link in the message Gmail sent or enter the confirmation code in the Accounts and Import section of your Gmail settings.
Whenever you want to send email from Gmail via SendGrid when you compose the email, in the “from” field select the SendGrid email (rami via SendGrid).
The will be send as like it has been send from the “email transmitter” (e.g it will send to myemail#mydomain.com).
Type the verification code and you are set.
Next time you want to compose an email from Gmail please select the field "FROM" and choose the new "transmitter email" (e.g. "Send mails via SendGrid"). Write your email and send it. It will be send via SendGrid.
If you login into your SendGrid account you can find many statistics on this email such as how many people have open this email. (https://sendgrid.com/logs/index).
The only thing that I couldn't figure is how use the SMTP protocol from GOOGLE JAVASCRIPT (not java) in order to manipulate my emails.
There are many SendGrid SMTP commands that can be added to the message headers but I couldn't figure how to do it.
The sendgrid API auth's from within the request. Simply use UrlFetch to send POST requests containing your API creds to the sendgrid endpoint.
If anyone comes across this answer as I did via a Google search, this update might help. The answer provided by #rmisegal is basically correct but you now use an API key from SendGrid.
You can setup an SMTP email API key via the SendGrid dashboard:
Log into your sendGrid Account.
Click on your account name in the top left of the dashboard and select Setup Guide from the drop down menu.
Press the start button next to the "Integrate using Web API or SMTP relay"
Follow the wizard steps to create your API key.
Follow the instructions provided rmisegal except provide a user name of apikey and use the apiKey from SendGrid as the password.

Resources