Take a look at the
bugzilla 2.12 package's
buglist.cgi line 887-, which does almost what you are asking.
It basicly comes down to that the first header you send you tell that what you are sending is a multipart message, where the first is your html and the second is your png picture.
T
I
M
T
O
W
T
D
I