Hi everyone,
This is my first time using Excel Office script and Power Automate.
On my Excel, I have created a simple script to draft an outlook email:
function main(workbook: ExcelScript.Workbook):myOutput {
let ws1 = workbook.getWorksheet("1st Batch 5pm");
let ws2 = workbook.getWorksheet("2nd Batch 11pm)");
let scriptws = workbook.getWorksheet("SendEmail");
let emailto = scriptws.getRange("I1").getText();
let cc = scriptws.getRange("I2").getText();
let client = ws1.getRange("I2").getText();
let date = ws1.getRange("I3").getText();
let reason = ws1.getRange("I3").getText();
let subject = "Late block " + date + " | Client limits for " + client;
//console.log(ws1.getName());
return {emailto, cc, subject};
}
interface myOutput{
emailto: string;
cc: string;
subject: string;
}
And in my Power Automate, I setup the flow.
1) Manually Trigger a flow
2) Run script
3) Draft an email message
When I TEST the flow, I am able to receive a draft with the expected value on my outlook.
However when I run the script from excel, it says "script run successfully", but I don't find any email drafted.
Why is the flow not triggered when I press the button?
I really appreciate if someone can point me to the mistake I am having.
Screenshots are attached.
Thank you,
WK