sendgrid / sendgrid-csharp

The Official Twilio SendGrid C#, .NetStandard, .NetCore API Library
https://sendgrid.com
MIT License
1.08k stars 585 forks source link

Dynamically change the APIKey #1210

Open sharatchandra99 opened 1 month ago

sharatchandra99 commented 1 month ago

Hi Team,

I have added the following D.I. in my code,

services.AddSendGrid(options => { options.ApiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY"); })

Now I am getting SendGridClient in my service with the APIKey. But I want to change the API key before calling "SendEmailAsync". Can you please suggest any possible way for this.