This question already has an answer here:
Say I have emailed a professor a few times, and told him I would like to work with him for my PhD etc. and that professor is interested:
How much of a factor could this possibly be in my application?
What about the (not so exact) opposite: somebody in the department doesn't like me, I apply there to work with somebody else etc.?