Think of it in the same way you would counting. You're technically "counting" from aaaa to bbbb, like binary.
aaaa -> 0000
aaab -> 0001
aaba -> 0010
aabb -> 0011
...
bbbb -> 1111
Without seeing what you've tried, I can't help you more than that, but essentially you need to enumerate all the "numbers" between your "lowest" element and your "highest" element by counting up through them.
For higher element counts, just treat your counting as counting in a higher base. For eight elements, Set = {a, b, c, d, e, f, g, h}, you would be counting up in what's essentially octal:
aaaa -> 0000
aaab -> 0001
...
aaah -> 0007
aaba -> 0010
...
hhhh -> 7777
It's the same way you enumerate all the combinations of 0-9 with a length of 4, by counting from 0000 to 9999.
Edit:
Thank you for posting your code. You're correct, you're doing permutations. A better way would be to use a multi-combination (combination with repeated elements in the ordererd combination set) algorithm like the one discussed here.