Send email dynamically with attachments

Can you put the excel in a good way to be done dynamically? ex: To,cc , subject,body,botname should be column names and the info rows…

Hi @Anil_G

i am here reading the same excel file then used for each activity, now what you want to put in “IN”. and in copy sheet i have provided the dynamic sheet name which is storing the names of company dynamically, i can use that variable right? in copy sheet option.

i will go step by step.

@RAKESH_KUMAR_Tiwari

For loop is for adding the sheets dynamically already if you are in a loop for dynamic sheet then dont use for loop again…else use get sheets and pass the output of get sheets which is the array of sheets

cheers

ok, pls see below code and confirm if i am going to right directions


is this correct?

now i want to delete the sheet once it is used


but getting error

@RAKESH_KUMAR_Tiwari

Why are you using office 365 again?

And why to delete sheet …rather after all the loop delete the file once and for all

Cheers

Hi @Anil_G ,

i am not sure how it is going to delete it, because i have not added any activity to delete it.

@RAKESH_KUMAR_Tiwari

Dont delete the sheet from original excel…in the loop before email use copy sheet and copy required sheet to a excel which is the attachment…and after send email delete the file which you just created…so that next iteration same file with different sheetname is created again

Cheers

Hi @Anil_G ,

refer the above image just to test the sequence.

i am reading the input file, then created temp file and copied the sheet in temp file.
now used outlook activity to send an email, now in attach file paased the file which is created, got got below error.

@RAKESH_KUMAR_Tiwari

  1. You need not open second excel I guess…and in copy aheet you have to specify the destination file and sheetname …
  2. Because you are using nested excel scopeand I believe the australia sheet is in first excel…and you used a copy sheet inside second so the sheet is being search in second when it is not present yet…so please use properly

If the excel is not present the second one…then use excel application scope with create if not exists and then create a dummy sheet1 which you can delete later on

Cheers

yes,

Actually it is working fine, it is attching the file, but my question is once i delete the file how it will create a file with same name again?

see the again img, i have craeted delete filename and deleted file i.e “Allcountrylist”

and the same file location passed in copy sheet destination property,

so my question is if it is in loop will it create a file with same name every time?

@RAKESH_KUMAR_Tiwari

First time did you create the file? No right…i did create…the same
Way how many ever times you deete it would create…untill the create if not exists is checked

Please run and check

Cheers

no no, i created that file in Data folder and passed it.

i have used excel application scope passed the original file path which has sheet containing the data"Australia", after that used copy sheet activity passed the location with file name(which is created in data folder) in destination property and passed sheetname.
after that used outlook activity to send email and deleting the file.

now please let me know at which step should i create a file, with which activity so that it will create same file name every time

if i use second excel scope and pass the file name by checking create file property after copy sheet, then i need to use again paste sheet activity and then i have to pass the location in attach file.

i tried using second excel before copy sheet, it throws error

@RAKESH_KUMAR_Tiwari

If you are creating it then just include that create excel step in your loop …then it wpuld be created and then sheet would be copied

Main excel scope…
For loop
Cretae excel or copy a templte excel
Copy sheet
Send mail
delete excel

Cheers

ok, see below img.

main excel - data\organization.xlsx
for each what needs to be passed here??
then passed the Allcountry.xlsx from data folder and then copy sheet.

@RAKESH_KUMAR_Tiwari

Above are to be placed inside loop

Cheers

that i got it,

i am asking what to provide expression in for each.?

@RAKESH_KUMAR_Tiwari

Use get worksheets and provide the output in the for loop

Cheers

i think, there is confusion.

what is happening now is

bot is trying to copy the sheet in test.xlsx, which it is not able to do it. and that throws error. and it is genuine.
image

we are missing something

@RAKESH_KUMAR_Tiwari

Copy sheet should be outside the first excel…

How ever you are creating excel in initilaize same way do it here and then use copy sheet after that…

Text excel scope should not contain copy sheet

Else it would look in the former only

Cheers