Extracting embedded images from emails using Microsoft.Graph.IMailFolderMessagesCollectionPage

24 views Asked by At

I have a webform application written in VB that reads an email inbox and retrieves all customer emails. As programmers, you know that people will attach and embed images in their emails when they send them. The code only looks for attachments, and I have been tasked to add to the function to check for embedded images. For brevity, I will give you the highlights. Even after reading the docs and looking at other examples, I have a hard time figuring out where or how to do this requirement.

First, I go and get all the emails from the inbox.

Dim AllMessages As IMailFolderMessagesCollectionPage = AsyncUtil.RunSync(Function() graphEmailService.ReadMailbox("[[email protected]]", "InBox"))

Then a bunch of other code that is not needed here ...

Then I do a While AllMessages.Count > 0

And inside that loop I do a For Each zMessage as Message In AllMessages

Now, this is this is where I test for the attachments.

If zMessage.HasAttachments Then
   While zMessage.HasAttachments
      For Each xFileAttachment As FileAttachment In AllAttachments.OfType(Of FileAttachment)

Any help will be appreciated.

0

There are 0 answers