0

In the previous code implementation the mail functionality was implemented using SmtpClient("smtp.office365.com"). and the image path was retrieved from Keyvault and implemented as below.

public void MailSend(){   
SmtpClient SmtpServer = new SmtpClient("smtp.office365.com");
MailMessage message = new MailMessage();
message.Attachments.Add(new Attachment(AzureVaultIntegrationLayer.RetrieveKeysFromKeyVault("Pic_Path")));
SmtpServer.Send(message);
}

Now in the current MS Graph API (mail.send API ) what would be the approach/implementation to pass this image from KeyVault in the message body.

Network_127
  • 93
  • 1
  • 6
  • (1) Register an application in AAD portal (2) configure the app to use a right Azure AD flow say, [delegated permissions](https://learn.microsoft.com/en-us/graph/auth-v2-user) or [application permissions](https://learn.microsoft.com/en-us/graph/auth-v2-service) (3) Get the token with necessary roles/permissions to access the protected resources (say, MS Graph) (4) Now you can call the Graph endpoint and [make API call](https://learn.microsoft.com/en-us/graph/outlook-create-send-messages) to create email messages, create the body, add the azurevault image part of it and send it over. – Dev Mar 23 '21 at 18:53
  • Thanks @Dev but I want to pass the above attachment from the KeyVault in the below code as mentioned on the [link](https://developer.microsoft.com/en-us/graph/graph-explorer) MS Graph Explorer Site.`var message = new Message` `{` `Subject = "Meet for lunch?",` `Body = new ItemBody` `{` `ContentType = BodyType.Text,` `Content = "The new cafeteria is open."` `},` `ToRecipients = new List()` `{` `new Recipient` `{` `EmailAddress = new EmailAddress` `{` `Address = "garthf@contoso.com"` `}` `}` `}` `};` – Network_127 Apr 08 '21 at 15:05
  • you may want to try the code sample provided at https://stackoverflow.com/questions/42374501/microsoft-graph-send-mail-with-attachment/42394414#42394414 to send email with attachments (replace the physical path with your keyvault info), @Network_127!! – Dev Apr 08 '21 at 15:25
  • Does it helped? – Dev Apr 11 '21 at 14:57

0 Answers0