Yes it would work. Sexual excitement in particular shuts down various analytic parts of the brain, making it easier.
There is nothing in theory that prevents us from creating realistic robotics and prosthetic sexual organs that would seem real enough to feel like the real thing; since you don't know what that partner would actually feel like.
In other words, it is possible to make it feel like you were having intercourse with a real person; and the robot can be programmed to physically respond like a real person.
That is mostly muscular action that isn't nearly as hard to emulate as expressions, vocals, eye movement, etc. We can do much of that with the motion dots you see being used when they translate a human actor's movements into a cartoon's movements. Similar recordings could be used to capture a library of copulation movements; and the robot could select to replay what seems appropriate for its physical situation.
Programmers would have far more trouble with the face, mouth, eyes, vocal tract, jaw, etc. Although we can capture motion; the actual mechanics of expression and voice are much more difficult to emulate.
As for whether it could convince you: Of course not, you know its a robot! But perhaps you can convince yourself that you had experienced what it would really be like to have sex with that person, within some margin of error, which might be enough to stop the obsession.