Convert/Cast Object type into MailMessage type

Hi everybody,
i want to convert my variable of type Object into an another variable of type System.Net.Mail.MailMessage, does anynone can help me?
I already tried with Convert class, but there isn’t an option to mailMessage type.
Thank you

1 Like

Hi! More context is needed around what the object is you are trying to convert, because a functional mailmessage needs to have certain properties. :slight_smile:

give a try on:
DirectCast(YourObjectVar, System.Net.Mail.MailMessage)


I get it from outlook and saved into a list of object

Then you should be using the get outlook message activity (or get exchange, if you’re on MS exchange) as this will pull the emails directly into mailmessage variable types.

Thank, it’s a solution :mechanical_arm:

1 Like

maybe we can avoid by remodelling. Can you give us some more context on your flow part for this? Thanks

I have a list of object that contains mailMessage and FTPObjectInfo, because for every item i do activity depending on the type.
I recognize the exact type of every element with a previous getType and a switch for every type I manage :wink:

can you check following (maybe it is failing)

MMList | List(Of MailMessage) =

YourObjectList.OfType(Of System.Net.Mail.MailMessage ).Cast(Of System.Net.Mail.MailMessage).toList

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