Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
gigocabrera committed Sep 14, 2022
1 parent 7710de2 commit e80f1af
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions MSGraphApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net.Http;
using System.Linq;
using OrderConfirmationEmailToPatient;

namespace EmailSenderService
Expand Down Expand Up @@ -33,8 +32,7 @@ public static MSGraphApiService GetInstance(AppConfig appConfig)
}
}
return _instance;
}

}

public async Task SendEmail(string subject, string Body, string fromEmailAddress, string toEmailAddress)
{
Expand All @@ -60,12 +58,9 @@ public async Task SendEmail(string subject, string Body, string fromEmailAddress
}
}
}
};

};
await graphServiceClient.Users[fromEmailAddress].SendMail(message).Request().PostAsync();

}

catch (ServiceException ex)
{
App.writetoLog(Newtonsoft.Json.JsonConvert.SerializeObject(ex));
Expand All @@ -76,7 +71,6 @@ public async Task SendEmail(string subject, string Body, string fromEmailAddress
}
}


private GraphServiceClient GetGraphClient()
{
App.writetoLog("GetGraphClient start");
Expand All @@ -99,12 +93,14 @@ private async Task<string> GetAccessToken()
App.writetoLog("GetAccessToken start");
var _httpClient = new HttpClient();
var url = String.Format("https://login.microsoftonline.com/{0}/oauth2/v2.0/token", _appConfig.TenantId);

var content = new FormUrlEncodedContent(new Dictionary<string, string> {
{ "client_id", _appConfig. AppId },
{ "grant_type", "client_credentials" },
{ "client_secret", _appConfig.AppSecret},
{ "scope", "https://graph.microsoft.com/.default" }
});

var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, new Uri(url))
{
Content = content
Expand All @@ -117,7 +113,6 @@ private async Task<string> GetAccessToken()
var token = myDeserializedClass.access_token;
return token;
}

}
}
}

0 comments on commit e80f1af

Please sign in to comment.