These days it's common for people to have close friends of both sexes, but there's a big difference between being friends and having an emotional affair. The question of whether you can remain friends with someone after having an emotional affair with that person depends on what you mean by the word "friend."
Everybody has their own definition of what constitutes cheating, but it's not realistic to restrict the definition to sex alone. The same partner who might be able to forgive you for making a mistake at the office party might be unable to get over your platonic connection with a friend or coworker if it involves true emotional intimacy. If you want to end an emotional affair and rebuild your relationship with your partner, you can't maintain an intimate relationship with the other person. The close emotional connection with another person is the problem you're trying to fix, and for as long as this connection continues, you're still having an affair.
When Friendship Isn't
When confronted by an angry partner, some people will defend themselves by saying there's nothing unusual or inappropriate about having a good friend of the opposite sex, or even a friend they find attractive, as long as they don't act on those feelings. However, a friendship and an affair don't feel the same. A good general rule about emotional affairs is that if it feels like you're doing something wrong even though you haven't technically done anything wrong, then you're crossing a line. Another guideline is that if you suspect your partner wouldn't be comfortable with what you're doing, you're probably right. Once you've crossed this type of line with a friend, you can't continue to claim you're "just friends" just because you haven't had sex. Recovering from an emotional affair requires scaling the friendship back to the point where inappropriate intimacy is not a potential problem.
Finding the Line
Emotional affairs often start in the workplace, and if you're going to keep working with the same person, you certainly don't want to be hostile or rude. However, you don't want to repeat the mistakes that led to the affair in the first place. People have lunch with their friends and coworkers every day, but there's a difference between a meal and a date and that difference is a feeling. An innocent lunch is an innocent lunch until it isn't. If you want to remain friendly with a coworker after ending an emotional affair, avoid having lunch with this person alone or doing anything else together without other people. present.
Making a Decision
If you're committed to working on the problems in your marriage, you might be able to overcome whatever led you to look elsewhere in the first place and find a new level of intimacy with your partner. In the worst-case scenario, you'll find out that you just can't save the marriage and both of you need to move on. You'll never know unless you make a real commitment to try, and that means putting an end to the distraction of emotional intimacy with someone else. If you can stay in touch with the other person without secret meetings, private conversations and the other hallmarks of an emotional affair, you might be able to become friends again with time. If the friendship with this other person is likely to remain a threat to your marriage, then you'll need to make a decision, because you can't keep both.