"Send Exchange Mail Message" activity - only attach if file exists

Using the Send Exchange Mail Message activity, I would like to be able to dynamically attach a file if it exists, and not attach if the file does not exist. What is the best way to do this? Thanks, Mark

Handle it with If and else condition

You can use File.Exists(“Your Attachment File Path”).ToString in IF Activity if it comes True than attach or in else part you can send mail without attachment.
Hope this helps you

Thanks very much Manjula and Anshul. But I think you’re talking about maintaining two separate “Send Exchange Mail Message” activities: one with the attachments and one without. I would prefer to keep only one activity and dynamically add the attachment if the file exists. What is the process for dynamically attaching a file to a “Send Exchange Mail Message” activity? Thanks again!

use if condition to check the path, using path exists activity.
If it is true, store path in Variable ,Else nothing in Variable . After checking this condition, pass the variable value to Attachments of send outlook activity .

Thanks Azam. I’ll give that a try.

What if…I want 3 conditions:
If condition A is True, send file 1,2
If condition B is True, send file 3,4
If condition C is True, send file 5,6

If condition A and B are true, send files 1,2,3,4
If condition A,B,C are true; send files 1-6

How can I accomplish this as simple as possible

If for someone is useful: I got it using invoke code:

something like the following:

' Input argument for the root folder
Dim rootFolder As String = in_RootFolder + "\images"
Dim dictionary As New Dictionary (Of String,Object) 
dictionary = Config

''''agregar al subject y body del correo
Dim subject As String
Dim body As String

' Variable to store attachments
Dim attachmentsArray As New List(Of String)()

'Table of stats
attachmentsArray.Add(Path.Combine(rootFolder, "screenshot_MX.png"))

' Check conditions and add file paths to the list
If dictionary("MX_Reporte_Ofertas").ToString = "T" Then
    attachmentsArray.Add(Path.Combine(rootFolder, "Oferta_FS.png"))
    attachmentsArray.Add(Path.Combine(rootFolder, "Oferta_WS.png"))
	subject = subject + "Ofertas"
	body = body + dictionary("Body_Ofertas_MX").ToString 
	
End If

If dictionary("MX_Reporte_Pedidos").ToString = "T" Then
    attachmentsArray.Add(Path.Combine(rootFolder, "Pedidos_FS.png"))
    attachmentsArray.Add(Path.Combine(rootFolder, "Pedidos_WS.png"))
	subject = subject + ", Pedidos"
	body = body + dictionary("Body_Pedidos_MX").ToString 
End If

If dictionary("MX_Reporte_Salidas").ToString = "T" Then
    attachmentsArray.Add(Path.Combine(rootFolder, "Salidas_FS.png"))
    attachmentsArray.Add(Path.Combine(rootFolder, "Salidas_WS.png"))
	subject = subject + " y Salidas"
	body = body + dictionary("Body_Salidas_MX").ToString 
End If

' ... add more conditions as needed

' Convert the list to an array if necessary
 'Dim attachmentsArray As String() = list_attachments_MX.ToArray()
list_attachments_MX = attachmentsArray.ToArray()
body_email_added = dictionary("BodySuccessEmail_MX").ToString  + body
subject_email_added =  dictionary("SubjectSuccesEmail_MX").ToString  + subject
' Output the result
'attachmentsArray