Read Outlook Subject and Save into Excel

Hi,
I will apologize up front if this is a duplicate post, but I have spent the better part of 2 days reading through posts on this subject and can’t seem to get mine to work 100% the way I am needing it to.

I have built an activity that looks into a specific folder in Outlook, reads the unread emails, and will save the subject in an excel file. All of that works just fine, but where I run into an issue is when there are multiple emails. I had a write cell activity and subject was being written over in Excel as it reads each email. I have tried the Write range activity, but get an error “Value of type ‘String’ cannot be converted to System.Data.DataTable” I have attached my workbook for review. Any feedback/examples would be greatly appreciated!
Main.xaml (8.2 KB)

Thanks,
MW

Hi @melaniewatson,

To clarify, this is what it’s currently doing,
1

And this is what you want it to do?
2

Yes that is correct.

@melaniewatson the most critical part of this workflow is that it has no incrementing index. Without an index, your code is doing exactly as it is told. It’s writing faithfully to the A2 cell, regardless of how many emails it checks. Notice now that it makes sense that the last email it looped through will be the final result of the A2 cell.
If you need further help, let me know and I’ll give you a more detailed walkthrough.

@pathLessTaken Thank you for the info. That 100% makes sense, but how do I get it to copy each subject line and then paste/save it into Excel, moving down the sheet? I am not sure how to make it perform this task. Are you able to provide me with an example?

@melaniewatson in your Write Range Activity the current range is set to “A2”. We need to set this so that it takes in your index variable. It should take the form of “A”+indexVariable.ToString. You need the .ToString part because “A”+indexVariable would just look like "A"2 or "A"3 in string format, which wouldn’t be a proper range.