Obviously there's a lot of confusion around the perfect tense, and we could fill volumes with descriptions and explanations of how it's used. However the thing to bear in mind is that it is basically a present tense, where present refers to whatever point in time the speaker is in when he uses it. With that as a reference, the perfect covers a timespan from a point before that "present" and up to it.
I have been writing this letter for an hour.
Here the "present" is now, and the timespan began an hour ago.
I had been writing the letter when Tony arrived.
Here the "present" is the point in the past when Tony arrived and the timespan is an unspecified period before that point. It simply describes what was going on before and up until the point that Tony arrived.
With the present perfect, you can mention when an action began, but you can't use any temporal that would suggest that you're referring back to the event as a finished, completed action at any point in the past, because, remember, it is for all intents and purposes a "present" tense - so it always refers to now. So *I've seen him yesterday - doesn't work because yesterday is over. However you can say: I've seen him today - if today is still today when you say it. At the end of today, you would have to say, looking back, I saw him today. (This may not be so in British English - I couldn't tell you. They often use the present perfect where we use the simple past).
The past perfect is different in this respect; You can refer to an action that continued or was valid up until the referenced point in the past as a completed action: He had written a novel in 2013. It simply cites it as an accomplishment of sorts - an action that was completed by that point in time.
Using the progressive simply implies that it was a repeated or ongoing action:
He had been writing a letter
= this is what he was engaged in up until the point referenced in the account, but not a completed action.
Also note, that the perfect is open ended; the action is understood to have started at a point before, continued or been valid through to the point reference (now or then) and may or may not continue. That is why: I haven't seen him today = not yet, not so far... but I may still see him at some point before the day is over.
I realize this is probably a vague answer to your question - more of a general overview. If you have any specific points you'd like me to clarify, that I missed, please ask. I've been teaching the perfect to Russians for a year and have gotten pretty good at it :)
As FumbleFingers and 1006a mention in the comments, there's nothing grammatically wrong with using the present perfect with "when". However, it imbues the question with nuance, since it often implies that there has never been such an occurrence (though you would expect there should have been.)
When have you written to your brother? (I have never known you to write to you brother).
This usage would normally include a word like "ever" to emphasize that the event never happened.
When has your brother (ever) visited us? (Your brother has never come to visit)
When has your mother (ever) come to visit and not found something to complain about? (your mother always complains about something in the house when she visits)
When has a politician (ever) told the truth? (Politicians never tell the truth)
Alternately, as a response the present perfect can be used to express doubt:
A. I did go to the dentist!
B. When have you been to the dentist? (I don't think you really have gone)
A. She went to see her mother in the hospital.
B. When has she been to see her mother in the hospital? (I don't think she has been to see her mother)
Best Answer
Both of your original conversations look fine. And yes, you can combine your responses into one. Here are some possible candidates.
For example #1:
"Yes, I have already sent that email (out) today."
"Yes, I had sent that email (out) earlier today."
For example #2:
"Yes, I have already sent that email (out) yesterday."
"Yes, I had sent that email (out) yesterday."
"Yes, I had sent that email (out) last week."
"Yes, I had sent that email (out) when I was in Japan."
NOTE: In your excerpt, there is "You CANNOT use the Present Perfect with specific time expressions such as: yesterday, . . ." <== But that is not really true. Your excerpt is an overgeneralized "rule" which is not always true. There are some conditions when past-time adjuncts (such as "yesterday") can be used in a present-perfect construction. For instance, there is a counter-example in CGEL, page 144, [13.ii.a] :
ASIDE: Here is a post with some info on the present perfect construction (though, unfortunately, it probably isn't directly related to your question) : What's the meaning of this present perfect sentence?
NOTE: CGEL is the 2002 reference grammar by Huddleston and Pullum et al., The Cambridge Grammar of the English Language.