Converting string to mail message

Hey all, I am trying to design a workflow:

  • Fetch emails and store in a orchestrator queue (strings, because you can’t store mailmessages in queue)
  • In a different sequence, retrieve these queue items
  • make these queue item strings into mail message
  • sort emails in different folder

This is my workflow to populate the queue:


The transaction items look like this:

And this is my workflow to retrieve them:


Now I want to convert these queue items back to a mailmessage so I can move the emails to different folders. Does anyone know how to convert this? Or should my workflow look completely different?
Thanks.

Hi @Floris_Maat ,

I believe we can’t store the mail message type in queue or convert it to string and retrieve.

This might be an alternate approach:

2 Likes

Hi @Floris_Maat

As same as the current logic that you are using, you can implement the architecture something like this:

  1. In the dispatcher process (i.e data to queue), you can just send the mail ID associated with each mail message that you have.
  2. In another process (which is called the performer), you can retrieve each mail ID present in the queue & fetch the mail from the server using mail ID.

Hope this helps,
Best Regards.

1 Like

Yes it is not possible to store a mail message type in a queue due to the queue only supporting primitive types. But what I am trying to achieve is converting a string to a mail message.

String to mail message is not possible because mail message is a complex datatype.

1 Like

@Floris_Maat

Use MailMes.Headers("Message-ID") which would be giving you unique id and this can be used in get outlook mail message filters and can get the required mail message again

Hope this Helps

cheers

1 Like

Yes I found something about the UID from @arjunshenoy reply. I will try this!

2 Likes

@Floris_Maat

Although it’s not advisable to convert a mail message to a string, if your objective is just to do so, you can use something called StreamReader.

Let’s say you have a string variable named strMailBody:

Using ms As New MemoryStream(Encoding.UTF8.GetBytes(strMailBody))
  mail = MailMessage.Load(ms)
End Using

You can refer the following thread for more:

Hope this helps,
Best Regards.

2 Likes

This worked, thank you.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.