Skip to main content
Solved

Send Email with attachment

  • December 22, 2025
  • 9 replies
  • 77 views

Forum|alt.badge.img+5

Hello Community,

 

How do I pass a variable to the email attachment field when using Send Email?

The attachment is generated dynamically each time the bot runs and is stored in a variable(string: sfname). I want the email to use that variable so the file gets attached to the case.

I’ve tried using the variable directly, but it doesn’t work and the email is sent with no attachment at all or doesn’t return a list value.

thanks
 

Best answer by Aaron.Gleason

@DanC25 Then use a File: Assign action and create a different List variable that holds files. 

I tested this and it works. 

9 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+14
  • Automation Anywhere Team
  • December 22, 2025

@DanC25 Create a new List variable (based on String typing). Then user the List: Add item action, passing in your $sfname$ variable as the item. Then use the List variable for your attachment. A List is used so you could theoretically attach multiple files to an email. 


Forum|alt.badge.img+5
  • Author
  • Navigator | Tier 3
  • December 23, 2025

@Aaron.Gleason 

 

thanks, I will try it tomorrow and update you on the outcomes 


Forum|alt.badge.img+5
  • Author
  • Navigator | Tier 3
  • December 23, 2025

@Aaron.Gleason 

I created a List variable with subtype String and added the $sfname$ variable as a value, but I got an error saying “at least one of the items is not of file type.”
It looks like the file type doesn’t allow me to use a string variable.
 


 

 


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+14
  • Automation Anywhere Team
  • Answer
  • December 23, 2025

@DanC25 Then use a File: Assign action and create a different List variable that holds files. 

I tested this and it works. 


Forum|alt.badge.img+5
  • Author
  • Navigator | Tier 3
  • December 23, 2025

@Aaron.Gleason 

The file name changes on each run and gets passed into a variable ($sfname$).
If I use a File type, how do i make sure it uses the variable and not a static file name or folder?


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+14
  • Automation Anywhere Team
  • December 23, 2025

@DanC25 That's what the File: Assign action does. 


Forum|alt.badge.img+5
  • Author
  • Navigator | Tier 3
  • December 23, 2025

@Aaron.Gleason 

does this will work?

 


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+14
  • Automation Anywhere Team
  • December 23, 2025

@DanC25 No. 

 


Forum|alt.badge.img+5
  • Author
  • Navigator | Tier 3
  • December 23, 2025

@Aaron.Gleason 
thanks

The file name changes on each run and is passed full path into a variable ($sfname$).

This is what I tried, and both approaches work:

#1
– Created an empty File variable (sfileattachment)
– Created an empty List variable (sattachment) with subtype File

– Used ‘File: Assign’ (Desktop file tab) with $sfname$ and ‘assign the input to’ : (sfileattachment)
– Used ‘List: Add item’ → list variable : sattachment and ‘item to be added’  : sfileattachment
– In Send Email, set Attachment → Variable → $sattachment$

#2
– Created an empty File variable (sfileattachment)
– Used ‘File: Assign’ (Desktop file tab) with $sfname$ and ‘assign the input to’  : (sfileattachment)
– In Send Email, set Attachment → List → Variable → $sfileattachment$