Problem with Mail.Messages and Casting

uiautomation

#1

Hi All

I am struggling to view emails that I have retrieved

I can scan a folder and check that a mail is present but I cant seem to open it. I think it has something to do with casting

System.Net.Mail.MailMessage
System.Web.Mail.MailMessage

I have tried to adjust to Web.Mail and that allows me to use .Body, .Subject etc but I cant seem to cast it correctly prior to this step

Trace below - Any suggestions

I had a look on forum but nothing to highlight step by step around what should be done

Email_Process has thrown an exception

Source: For each

Message: Unable to cast object of type ‘System.Net.Mail.MailMessage’ to type ‘System.Web.Mail.MailMessage’.

Exception Type: InvalidCastException

System.InvalidCastException: Unable to cast object of type ‘System.Net.Mail.MailMessage’ to type ‘System.Web.Mail.MailMessage’.
at UiPath.Core.Activities.ForEach1.InternalExecute(NativeActivityContext context, IEnumerator valueEnumerator) at UiPath.Core.Activities.ForEach1.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


#2

Hi @RogerFenergo,

If you are reading the mail from uipath activity it will return the System.net.mail.mailmessage datatype. You can’t convert net to web.
mail_For

Regards,
Arivu :slight_smile:


#3

Thanks - how do I read the content though


#4

Hi @RogerFenergo,

Using this data type its self you can use, refer the previous post and try it.

Regards,
Arivu :slight_smile:


#5

Here is some more detail on the error


#6

Hi @RogerFenergo,

change the Properties->TypeArgumaent to “System.Net.Mail.MailMessage”

Regards,
Arivu :slight_smile:


#7

Perfect - Thanks Arivu