When I send an email via outlook for my custom domain it goes to the recipients inbox. However, in my c# program when when i use MS Graph API to send an email on behalf of the user it goes into the spam folder. I believe this is because the email may be lacking SPF and DKIM validation when sending via MS Graph API. So I have been trying to figure out how to add SPF and DKIM to my email. When I have used email services like namecheap they provide you upfront with the spf record, the mx record, and the DKIM record and I add it to my DNS (an azure service) and all is dandy. However, I am trying to do everything in Azure for this one project including email integration. So I have already verified my custom domain in azure via dns records. However, there seems to be two MS articles to create DKIM records and I am confused which is the correct path. First, I can go to the azure portal and create a email communication service and add a custom domain and then it gives me the records to create for domain verification, spf, and dkim. I added those manually to my azure dns service and everything says verified as shown in this screenshot:
A different article in MS says to add DKIM records you do it through the https://security.microsoft.com/ and there you can setup DKIM but it asks me to add two different cname records compared to when i did it in the azure portal. Close in name but still different.
So I have done both methods now and I am not sure which to keep. The domain is platformperry.com and regardless of whichever method i use the DNS checkers show no cname records but do show the spf ones. So I am lost as to which method to use and why neither seems to show up on these dns checkers (its been about 15 minutes so not sure if it takes longer to propogate these days). Either way my emails still keep going to spam. My code is as shown below:
var requestBody = new Microsoft.Graph.Users.Item.SendMail.SendMailPostRequestBody
{
Message = new Message
{
From = new Recipient
{
EmailAddress = new EmailAddress
{
Address = emailMessage.From.EmailAddress,
},
},
Subject = emailMessage.Subject,
ToRecipients = ToRec,
CcRecipients = CcRec,
BccRecipients = BccRec,
Attachments = attachments,
}
};
await GetGraphClientWithManagedIdentityOrDevClient().Users["[email protected]"].SendMail.PostAsync(requestBody);

