Hi Ppuddick,
From the Designer, you can go to Tools->Data Connections. Select your e-mail connection and click modify. The default option is to attach the form to the e-mail data connection. Once you set that up, you can write code to it and it should still attach the form. Hope this helps.
Patrick Halstead [InfoPath MVP]
InfoPathDev
Patrick Halstead
Project Manager at Qdabra