You need to create a web user control (.ascx file) and then load that control and pass it to CreateMailMessage.
// Create a dummy page and use it to load a dummy control so that CreateMailMessage() will not complain
Page page = new Page();
DummyControl control = (DummyControl)page.LoadControl("~/DummyControl.ascx");
MailMessage message = mail.CreateMailMessage(reciever, RecieptReplacements, dummycontrol);
Take a look at this answer , which explains why and provides the above solution.
source
share