I have 5 different type of email which can be differentiate through naming convention of the attachment present
Which is the best way to get the mail type as each of them have different functionality to be done according to the name present in attachment
Get Outlook Mail Messages
Output: mailMessages (List<MailMessage>)
For Each email In mailMessages
If email.Attachments.Count > 0
For Each attachment In email.Attachments
If attachment.Name.Contains("Type1")
Perform Action for Type1
Else If attachment.Name.Contains("Type2")
Perform Action for Type2
Else If attachment.Name.Contains("Type3")
Perform Action for Type3
Else If attachment.Name.Contains("Type4")
Perform Action for Type4
Else If attachment.Name.Contains("Type5")
Perform Action for Type5
Use Normal for each Loop only.
I hope this will help you
–>Retrieve Emails through GetOutlook or Get Imap Mail Messages
–>Loop through For Each Statement
–>Inside use Switch statement with expression attachment.name
Use the Get Outlook Mail Messages activity.
Use a For Each activity to iterate through the list of emails.
Inside the loop, use an If activity to check if the email has attachments.
If email.Attachments.Count > 0 Then
’ Process attachments
End If
Use another For Each activity to loop through each attachment of the email.
Extract the name of each attachment using the Name property of the attachment.
For Each attachment In email.Attachments
Dim attachmentName As String = attachment.Name
Next
Use an If or Switch activity to determine the type of email based on the attachment name.
If attachmentName.Contains(“Type1”) Then
’ Handle Type 1 email
ElseIf attachmentName.Contains(“Type2”) Then
’ Handle Type 2 email
ElseIf attachmentName.Contains(“Type3”) Then
’ Handle Type 3 email
ElseIf attachmentName.Contains(“Type4”) Then
’ Handle Type 4 email
ElseIf attachmentName.Contains(“Type5”) Then
’ Handle Type 5 email
End If
Based on the type determined, invoke different workflows or activities specific to each type of email.