Attach files from dynamic folders to "Send Outlook Mail"

uiautomation
email

#1

Hi,

Im having some problem attaching .xlsx files from a folder to “Send Outlook Mail” activity.
There are 5 .xlsx files that i want to attach, but i cant get it working?

I also want to do the same but with a dynamic number of files?

Hope someone can help me with how this can de done.


Send outlook mail
#2

Are you getting any error message? I hope you are using attachfiles property and passing file variable into path column in send outlook email activity.

To pass dynamic files , you can create a mailmessage object and attach files to it and pass that object in your send outlook email activity.

Someone provided sample in the past, please search the forum.


#3

Hey @SoJo

Hope This link might give you an idea :slight_smile:
How to insert attachment in UI path SMTP activity

Regards…!!
Aksh


#4

hi aksh1yadav i m unable to open your project on my ui path.
The issue i am facing is i can attach one or more files when i use the hardcoded path but how can i make it send all the files that exist in an a folder
?


#5

What version of Uipath Studio you are using?
Well mine was 2016.2.6274.

You can Get all files from Directory by using System.IO.Directory.GetFiles(“Attachments”) or Directory.GetFiles(“Attachments”)(If System.IO Namespace is already imported).

Basic Flow:

1. String[ ] fileNames_to_be_attache= Directory.GetFiles(“Attachments”)
2. System.Net.Mail.Message mail = new MailMessage()
3. For Each with type argument String.

foreach item in fileNames_to_be_attache{
System.Net.Mail.Attachement attachment = new Attachment(item,System.Net.Mime.MediaTypeNames.Application.Octet)
Invoke method -activity
type - (null)
TargetObject - mail.Attachments
MethodName - Add
}
parameter for invoke method-

Rest steps you can find in the image:

Regards…!!
Aksh


Checking For Files Inside Local Machine Directory
How to dynamically loop through the PDF's that are saved on our local drive
#6

Hi Akash
i have downloaded ur solution its showing it has files in folder but while sending mail its not attaching the files.


#7

check your local path and folder which you are giving it.


#8

Hi

i have replaced Send SMTP mail to Send Outlook mail so property Forward - > MailMessage -> mail was pending to be added now its working.


#9

thanks Akash


#11

Use of below statement in ur code
new Attachment(item,System.Net.Mime.MediaTypeNames.Application.Octet)

Got Directory not found exception while executing above Xaml file.


#12

Cross check Your directory … name :slight_smile:


#13

Even i am trying with send outlook,what we should change in code?Can you post your sample code here


#14

Hi @aksh1yadav I am using your attach and send mail for outlook and i am able to snd mail but attachments are not getting attached to mail and i have bverified the path in write line it is showing the two file names properly ?