1
votes

When I am sending mail through gmail service account using gmailapi it is showing the following error.

Errors [ Message[Precondition check failed.] Location[ - ] Reason[failedPrecondition] Domain[global] ] My Gmail service account is a free gmail account. Authentication with service account is working but send mail is not working and showing above error. Please suggest me how to resolve the issue. Here is code i am using to send mail

'''

 MimeMessage email = createEmail(to, from, subject, body);// calling the createEmail Function to create the mail message
                Message message = new Message();
                message.Raw = StringToBase64url(email.ToString());
                var sa1 = service.Users.Messages.Send(message, userId).Execute();
                return sa1;'''
1
try this seems like a similar issue stackoverflow.com/questions/29327846/…Ricky G
Service accounts cannot send emails. They can impersonate regular accounts and send emails on behalf of them, but they cannot send them by themselves. Take a look at stackoverflow.com/a/29328258 for how to impersonate another account.Iamblichus
Does this answer your question? Gmail REST API : 400 Bad Request + Failed PreconditionRob

1 Answers

1
votes

try to activated option allow less secure app access in your google account