@preettyy_312024
Please take the time to understand how it functions. Attempt to debug the code so that you can gain a better understanding as well.
- Line 8: You will iterate through all the column names.
- Line 9: We are verifying whether the current column name starts with "Email" or not.
- Line 10: We are retrieving the email ID from the current row and checking whether it's empty or not.
- Line 11: We are checking if the ToAddress variable is empty or not.
- Line 12: If the ToAddress is empty, it will fetch and save your email ID in this variable.
- Line 13: Else, if the ToAddress is not empty.
- Line 14: It will add another email ID with a semicolon.
Once loop of column name is completed then it will send email to Toaddress folks.

Code:
Outlook.Launch Instance=> OutlookInstance
Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Boot\\Invoice_Details.xlsx''' Visible: False ReadOnly: False Instance=> ExcelInstance
Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
SET ColumnNames TO ExcelData.ColumnHeadersRow.ColumnNames
SET ToAddress TO $'''%''%'''
LOOP FOREACH CurrentItem2 IN ExcelData
SET ToAddress TO $'''%''%'''
LOOP FOREACH CurrentItem IN ExcelData.ColumnHeadersRow.ColumnNames
IF StartsWith(CurrentItem, $'''Email''', False) THEN
IF IsNotEmpty(CurrentItem2[CurrentItem]) THEN
IF IsEmpty(ToAddress) THEN
SET ToAddress TO CurrentItem2[CurrentItem]
ELSE
SET ToAddress TO $'''%ToAddress%;%CurrentItem2[CurrentItem]%'''
END
END
END
END
Outlook.SendEmailThroughOutlook.SendEmail Instance: OutlookInstance Account: $'''Deenu@office365journey.onmicrosoft.com''' SendTo: ToAddress Subject: $'''test''' Body: $'''test''' IsBodyHtml: False IsDraft: False
END
Input Excel:

Output of first row iteration:

Second Row:

Output:

Thanks,
Deenuji Loganathan 👩💻
Automation Evangelist 🤖
Follow me on LinkedIn 👥
-------------------------------------------------------------------------------------------------------------
If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀