Share via

Mails send using MS Graph API are received as spam

Luc Nuyts 1 Reputation point
2022-08-11T07:44:08.78+00:00

Hi,

since a few weeks, whitout any code change for the past year, mails send using the Graph API received as spam, sending the identical message (identical subject, body, attachments) via outlook to the identical recipient are received normaly.

Hope you can help us out with this one

grtz,

Luc

public async Task<bool> verzendAsync(bericht mailMessage, string aan, string cc, string bcc)  
        {  
            bool res = true;  
  
  
            var message = new Message  
            {  
                Subject = mailMessage.Onderwerp,  
                Body = new ItemBody  
                {  
                    ContentType = BodyType.Html,  
                    Content = mailMessage.Body  
                },  
                From = setRecipient(User),  
  
                ToRecipients = setRecipients(aan),  
                CcRecipients = setRecipients(cc),  
                BccRecipients = setRecipients(bcc)  
            };  
  
  
            if (mailMessage.Bijlagen == null || mailMessage.Bijlagen.Count == 0)  
            {  
                await graphClient().Users[User.email]  
                   .SendMail(message, true)  
                   .Request()  
                   .PostAsync();  
            }  
            else  
            {  
  
                // de mail wordt als draft bewaard om later de bijlagen aan toe te voegen  
                Message draft = await graphClient().Users[User.email]  
                    .Messages  
                    .Request()  
                    .AddAsync(message);  
  
  
                if (await setAttachements(mailMessage.Bijlagen, draft))  
                {  
                    // na het eventueel toevoegen van de bijlagen, wordt het bericht verzonden  
                    await graphClient().Users[User.email].Messages[draft.Id]  
                           .Send()  
                            .Request()  
                            .PostAsync();  
  
                }  
            }  
  
            return res;  
  
        }  
Microsoft Security | Microsoft Graph

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.