I am using copilot studio latest version with harness and i am facing issue with file content

Yadav, Vikas 0 Reputation points
2026-09-30T11:48:24.4333333+00:00

I have built an agent whose responsiblity is based on the knowledge mapping which is CSV file it should be able to first generate all the details such as to,cc,subject,body etc and it should also be able to attach the input document which is added in chat by user and send the attachment with the help of send email v2 tool of outlook with the attchment but when i am trying to do the same it is not able to fetch the attachment document which was in the chat so how can i add this even though there is no metadata as well for the file except the name there is no content which can be accessed and the file can be sent to email. sometimes email works but the file is cuorrupted as there is no data its only the name.

Microsoft Copilot | Microsoft 365 Copilot | Development
0 comments No comments

2 answers

Sort by: Oldest
  1. AI answer

    2026-09-30T11:48:42.4533333+00:00

    Use the file from System.Activity.Attachments and pass both the file name and file content explicitly to the Outlook action. The corruption happens when only the file name is passed and contentBytes is empty or mapped incorrectly.

    Recommended setup:

    1. In the topic, first capture the uploaded file.
      • Use a Set variable value node with:
             First(System.Activity.Attachments)
        
      • This returns the attached file as a record.
    2. Extract the two fields needed for email attachment handling:
      • File name: .Name
      • File content: .Content
    3. If the user might start the conversation with or without a file, combine both patterns:
      • Check First(System.Activity.Attachments) first.
      • If no file is present, route to a Question node with Identify = File.
      • In the Question properties panel, enable Include file metadata.
    4. For Send an email (V2), the attachment input must be wrapped as a record with contentBytes and name keys.
      • Use this shape:
             { contentBytes: Topic.userReceipt.Content, name: Topic.userReceipt.Name }
        
      • If filling from System.Activity.Attachments directly for a tool, use:
             If(
                 IsEmpty(System.Activity.Attachments), 
                 [], 
                 [{ contentBytes: First(System.Activity.Attachments).Content, name: First(System.Activity.Attachments).Name }])
             )
        
    5. On the Tools page, file inputs must be set with Custom value and a Power Fx formula.
      • Do not use Dynamically fill with AI for file inputs.
    6. If the file still appears empty, verify channel and environment support:
      • File input is supported on Microsoft Teams, custom website/demo website, Facebook, Omnichannel for Customer Service, Microsoft 365 Copilot, and the Test your agent panel.
      • File input is not supported on voice, telephony, or SharePoint channels.
      • In a customer managed key enabled environment, files can be added as input, but the agent does not process them.
    7. Check file limits and behavior:
      • Maximum attachment size is 16 MiB per file.
      • Failed attachments are skipped and the message still continues.

    For the scenario described, the most likely fix is:

    • store First(System.Activity.Attachments) in a variable,
    • map .Content to contentBytes,
    • map .Name to name,
    • and pass the attachment object to Send an email (V2) using Custom value.

    If only the name is available in the current topic path, the file was not captured through the file input path correctly, or the attachment input was mapped in the wrong format.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

  2. Yadav, Vikas 0 Reputation points
    2026-09-30T11:51:37.23+00:00

    I dont have the topic feature in the new harness copilot so how come i will be doing this?

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.