Send email dynamically with attachments

Hi All,

Hi @Anil_G you are aware of the requirement.

i need to send email dynamically from excel file img reference below

i need to read TO, CC,Subject, Body,BOTName. also need to attach attachment as excelsheet which has data, img below
image

and once it sends an email , need to delete sheet, so it will be in loop.

i have done this much, below img for reference.

Thanks in advance
Rakesh

Hey @RAKESH_KUMAR_Tiwari ,
Is the order of these are always the same?

image

Regards,

As of now yes.

@RAKESH_KUMAR_Tiwari ,

Remove the for each loop
Drag and drop the “send mail” Activity

in To Section : email_List(1)(1).ToString
in CC Section : email_List(2)(1).ToString
Subject : email_List(3)(1).ToString
Body : email_List(4)(1).ToString

Regards,

ok let me try

Hi @Jithesh_R ,

can you pls see the below error?


which variable i need to change

@RAKESH_KUMAR_Tiwari ,
Remove for each loop After Read range your input will be in Data Table that is “email_List” Right?
Then directly drag and drop “Send mail” Activity inside that provide

in To Section : email_List(1)(1).ToString
in CC Section : email_List(2)(1).ToString
Subject : email_List(3)(1).ToString
Body : email_List(4)(1).ToString

Regards,

After removing for each, getting below error.

image

@RAKESH_KUMAR_Tiwari ,
I believe your email_list is the DataTable Type
Check this here DT_Input is my DataTable

image

Regards,

yes, it is a datatable for me as well,

is it a package issue?

image

how your activity looks like and how mine is looks like?

@RAKESH_KUMAR_Tiwari ,
Yes in your case in To section it will take Array of strings and in the subject it will take string so you can add like this

image

Regards,

yes, actually i installed the package.

i want to write 5th row in new line in Body, can you pls help me in writting the expression?

@RAKESH_KUMAR_Tiwari ,
You cant do like that if you want both Body and bot name together before the Send mail activity use "Create HTML Content " Activity .
Configure it Like this

Then map it like this

image
image

Then use the same variable inside the Activity

Then add the HTML Content variable to your mail body
image

Make sure you tick this property in the send mail activity
image

Regards,

yes it is working fine, thanks

but i need to attach sheet with email, which is dynamic.
it is in same excel file where i am reading the emails, but it is dynamic, so basically it has some data which i need to send as an attachment.

How to achieve?

Hi @Anil_G

@RAKESH_KUMAR_Tiwari ,
Which sheet you are talking about? if the sheet is in the same excel file then you can send that excel file in the mail using attach files option.

Regards,

Hi,

problem is sheet is dynamic, so scenario is i am extarcting some data from website and writing it in same excel fie with sheet name(ABC), so that sheet i want to send them and delete the sheet.
so next time BOT will again scrape the data from website and store it in same excel file with sheetName (BCD) and send it in email and delete sheet. it will be in loop.

img for reference
image

@RAKESH_KUMAR_Tiwari

Try using copy sheet activity and copy the required sheet only to a separate excel and then attach that excel or in the loop you can always extract to samw excel name but different sheetnames so that in attachment you will give only one path always but sheets change depending on the variable

Hope this helps

Cheers

Hi @Anil_G ,

Thanks for replying,

can you pls elaborate in step by step with activity? if possible

see, i am writing in this way like

i am writing the extarcted data and again using same locaton and used sheet variable.


now it should be in loop?

Then how to configure here?

@RAKESH_KUMAR_Tiwari

Here configure the same file name…dont change it…but in the loop create a new excel always and after sending delete and create with new sheet again using a copy sheet

  1. For loop on the excel sheets
  2. Copy sheet activity with copy to excel1.xlsx and sheetname would be currentitem
    Sheetname
  3. Send email with attachment as excel1.xlsx
  4. Delete excel1.xlsx

Hope this helps

Cheers