Let $\mathscr F$ be a coherent sheaf on a noetherian scheme $X$ and assume that ${\rm supp}\mathscr F=X$. Let $Z\subset X$ be a subscheme of codimension at least $2$ and $U=X\setminus Z$. Let $\iota:U\hookrightarrow X$ denote the natural embedding and assume that $\mathcal F_x$ is $S_2$ for every $x\in Z$. Now the $S_2$ assumption implies that $$ \mathscr H^0_Z(X,\mathscr F)= \mathscr H^1_Z(X,\mathscr F)=0 $$ and the HartogHartogs type extension is equivalent to $$ \iota_*\iota^*\mathscr F\simeq \mathscr F. $$ Finally one has the exact sequence $$ \mathscr H^0_Z(X,\mathscr F) \to \mathscr F\to \iota_*\iota^*\mathscr F \to \mathscr H^1_Z(X,\mathscr F).$$
[See also this MO answer]