I want to create a class which has a function to send email.
I want it to send the email directly, if the relevant properties have been set (this.subject, this.toemail etc.) But if these are not set, I want to show a form to the user (which has some textboxes on it) to fill out these parameters.
I don’t know what is the best way of doing this. I also don’t know where to start. Could you show me an example or point me somewhere?
You are mixing concerns.
I suggest you have logic that determines whether all relevant information is present for the email and, if not, displays a form whose sole responsibility is to gather the missing information.
Once the missing information is provided, have your email sending logic go ahead and finish sending the email.
I don’t know exactly how your code is structured, but here’s a stab at what the pseudo-code might look like.