I have created a SharePoint 2010 workflow to send an email on list. when I add item into list using code, it not triggers the workflow. however when I enter Item manually it works fine.
A common issue is that workflow not starting automatically as System Account. So don't run the code with system account.
Similar issue post for your reference:
I had the same issue. I went through the following:
- I checked SPTimerV4-- it was running.
- I ran Get-WFFarmStatus and Get-SBFarmStatus-- both were good.
- WF running as System Account: false-- all good.
- Item being created by System Account: false-- all good.
- Checked/unchecked manual start/auto start in Designer, then republished-- done.
None of them worked. (You can google each of the above to perform them accurately.)
At the end of my wits, I thought of recreating the WF. I began with a simple workflow that did nothing but to log a message on the history list. I checked manual/auto at creation. Saved and published. I created an item in the target list.
This new WF ran-- and so did the old problematic WF!
I am thinking that there is an internal create-event hook that broke with the old WF. When the new WF was being hooking into the create event, it restored the hook for the old WF. I will probably never get to confirm this. Just the same, it resolved my issue and that is what matters to me now.