Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Check Email Attachment Filenames in Workflow

(0) ShareShare
ReportReport
Posted on by 25

Hello

I'm working on an email workflow in Dynamics so that, whenever an email enters system, it is checked for whether a specific attachment is included. i.e. it just checks the email attachments for an attachment with a given filename string, and then either performs an action on that record (or doesn't) accordingly.

Whilst I can make a view that will filter all emails with this attachment, I cannot find the same Attachments (Item) option in the dropdown in the workflow wizard.

Please may I have some advice on how to achieve this. I have lots of additional workflow solutions (like Jason Latimer's ones), and delete/add attachment by name having counted attachments before and after was one idea. But for whatever reason it never thinks the count has changed when I compared the before count to the after one.

Thank you

  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Check Email Attachment Filenames in Workflow

    Hi,

    Thank you.

    I am happy to help you.

    Thanks,

    Pradeep.

  • jmillsjmills Profile Picture
    jmillsjmills 25 on at
    RE: Check Email Attachment Filenames in Workflow

    Amazing! Thanks so much - it now runs successfully. You've been a fantastic help and it really is appreciated!

  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Check Email Attachment Filenames in Workflow

    Hi,

    I will try again.

    Screenshot of your Power Automate:
    pastedimage1630951365325v1.png

    Please add steps 2 as shown below:
    pastedimage1630950856902v3.png
    Now,

    In the next steps you use the Step2 File Name attribute. To check your specified condition For e.g.

    pastedimage1630951112362v4.png

    Note:

    In Power Automate We access any fields values of previous steps.

    E.g. in If condition i can access the field from Step 1 and Step 2. Same applies for Other part of Power Automate.

    Hope this helps.


  • jmillsjmills Profile Picture
    jmillsjmills 25 on at
    RE: Check Email Attachment Filenames in Workflow

    hi - i am honestly so grateful for your help and very sorry that i'm not quite getting there

    this was the full process that was failing

    - i initially analyse the attachments

    - then initialise the string variable containing the text i'm looking for

    - then i check to see if the attachment name contains the string (but this is where it fails)

    how exactly would i retrieve the record again?

    pastedimage1630950038352v1.png

    when i do get record by id as follows, i cannot then reference this output in the check condition stage afterwards? it still only lets me reference the initialised variable I set containing the text string

    pastedimage1630950119441v2.png

    thanks so so much again

  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Check Email Attachment Filenames in Workflow

    Hi,

    Yes. In If condition the fileName field is Null.

    To Resolve that we need to retrieve same record again.

    In previous screenshots which i was shared. There No.4 screenshots performs the same action.

    There, i am retrieving same entity record to get FileName. because initially it was not present.

    Thanks,

    Pradeep

  • jmillsjmills Profile Picture
    jmillsjmills 25 on at
    RE: Check Email Attachment Filenames in Workflow

    Thanks so so much Pradeep - I'm really appreciating your help

    pastedimage1630949074460v1.png

    i'm trying to just check for the attachment name with the "check condition" stage, as per the below (but get the above error):

    pastedimage1630949117229v2.png

    When I audit the attempted running of the process, and look at the raw outputs for the attachment record, I note that there is no output for the filename:

    pastedimage1630949194533v3.png

    Could this be why the above issue is happening? i.e. because it cannot find the filename field for the attachment?

    Thanks

  • Suggested answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Check Email Attachment Filenames in Workflow

    Hi,

    Sure. happy to help you.

    Please find the screenshots:

    1.

    pastedimage1630943937722v1.png

    2. 

    pastedimage1630943967284v2.png

    3. 

    pastedimage1630944024894v4.png

    4.
    pastedimage1630944046105v5.png

    Thanks,
    Pradeep.

    Please mark this as VERIFIED if it helps.

  • jmillsjmills Profile Picture
    jmillsjmills 25 on at
    RE: Check Email Attachment Filenames in Workflow

    Thanks very much - I can now see where I should do this

    Please could you show me the original screenshots with each step of the process opened out (rather than just being the bar with just the title)

  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Check Email Attachment Filenames in Workflow

    Hi,

    Sure.

    Power Automate: In power automate we have lots of connectors which we can use in our development.

    Here we do not need write the complex code C# etc. instead we have connectors.

    Let us discuss about your scenario.

    In your case you have WORKFLOW and in workflow based on business requirement we used to add the steps(i.e. Create, Update etc)

    Same logic we can use in Power Automate as follows:

    Lets say when Email record received IN CRM system then CRM create Email Records in Email Message entity.

    Now if email contains the attachment then Attachment record will be created in Activity MIME Entity .

    By using above logic I have developed above Power Automate.

    As you know all data get stored in Dataverse hence we have used the Dataverse Connector in Power Automate.

    Hope this helps.

    Thanks,
    Pradeep.

    Please mark this as VERIFIED if it helps.

  • jmillsjmills Profile Picture
    jmillsjmills 25 on at
    RE: Check Email Attachment Filenames in Workflow

    Hi Pradeep - thanks so much for this. I've not really used Power Automate before. Could you explain in a little bit more detail the process of "We can create Power Automate on Attachment(activitymimeattachment) Entity"

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans