in order to add some more logic and structure:
1)
when speaking about time you should use -에
this works every time, no additional rules :)
ex)
3시에 친구를 만날 거예요 = I(we,he,she,they) will meet with friends at 3 o'clock.
2)
when speaking about location of somebody or something (but NOT of location of an action!) you should use -에
with -에 here you only say that something or somebody IS somewhere.
for somebody is DOING something somewhere or something BEING HAPPENING somewhere --> check #3
ex)
Where are you? - 저는 학교에 있어요. = I am at school.
Where is the grandfather? - 할아버지께서는 수영장에 계세요. = Grandfather is in the swimhall.
3)
when speaking about location of an action or activity you should use -에서
ex)
Where do you study? - 저는 학교에서 공부해요. = I study at school.
Where does grandfather swim? - 할아버지께서는 수영장에서 수영을 하세요. = Grandfather swims in the swimhall.
4)
when speaking about direction -에 means 'to' and -에서 means 'from'
ex)
Where are you going to? - 저는 학교에 가요. = I am going to school.
Where are you going from? - 저는 학교에서 가요. = I am going from school.
Where are you from? - 저는 미국에서 왔어요. = I am from the USA.
5)
regarding the position of -에 and -에서
these are POSTfixes, and are being placed only AFTER the word which they belongs to, and WITHOUT SPACE between the word and 에(서).
so, if you see 에(서) before a word (like in your example, 에 was written before 마음), it simply means that 에(서) belongs to the previous word. ;)
hope the scheme is more or less clear now :)