Getting errors while running Email Automation

Hi everyone, when I run a email Automation I get these error messages:

Main.xaml: Compiler error(s) encountered processing expression ““item””.
Value of type ‘String’ cannot be converted to ‘System.Net.Mail.MailMessage’.

Main.xaml: Compiler error(s) encountered processing expression ““item.Subject.ToLower.Contains(“resume”)””.
End of expression expected.

Can you please help.

Hi @Hallgrimur_Ingolfsson_HI

Could you share screenshot for this expression ?

The error is about mismatch type in expression

If you do this in a loop activity, like for each, make sure in type argument is set as System.Net.Mail.MailMessage

“item” is of type System.Net.Mail.MailMessage. It appears that you are trying to assign a string that is why you are getting error.

Hi,

Before the If condition take an assign, activity and give below syntax:

Assign=> MailSubject= item.Subject

If
MailSubject IsNot Nothing AndAlso MailSubject.Contains(“resume”)
Then
do required process
Else
do required process
End If

Hi @Hallgrimur_Ingolfsson_HI

mailMessages: System.Net.Mail.MailMessage

For Each currentItem In mailMessages
    If currentitem.Subject.ToLower().Contains("resume") 
      Then
        ' Do something with the emails that have "resume" in the subject
        filteredEmails.Add(item)
       Else
    End If
Next

Hope it helps!!

try this

For Each item In yourMailMessagesCollection
If item.Subject.ToLower().Contains(“resume”) Then
’ Your code to handle emails with “resume” in the subject
End If
Next

Hi, and thanks for the good advice. Now I have narrowed it down to the error:
Main.xaml: Compiler error(s) encountered processing expression “mailResumes”.
Value of type ‘System.Net.Mail.MailMessage’ cannot be converted to ‘System.Collections.Generic.List(Of System.Net.Mail.MailMessage)’.

Brg.
Hallgrimur

Hi,

I believe you have taken the all the mails in the List using Get outlook mail messages. then, you are iterating the all the mails. if yes.

change the Type Argument from string to MailMessage in For each property.

Hi, I am still getting error. Brg. Hallgrímur

Hi

You need populate for ForEach field with item

Remove double quotation in IN field

Go back to Get Mail Message

Click in Output field and clear the value

Make sure to populate output with a variable mailResumes

If it wasn’t created yet, click on output field then ctrl+k and give the name mailResumes

Then try again

Take a look in attached project

EmailAutomationSolution.zip (31.5 KB)

I removed the IF condition and use Filter property in Get IMAP Mail Messages to retrive only mails with resume in subject

You need to setup the IMAP properties

Cheers,

Thank you Henrique for your input.

1 Like

Thanks for your input AJ_Ask

Thank you for your input Neha.

Thank you for your input Parvathy.

Thank you for your input Shah.

Thank you for your input Siva.

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