asp form submit

Associate
Joined
2 Jul 2004
Posts
1,402
Hi,

I need a form submition feature from a User which will include the users name, company, and message text. This message is to be received via e-mail.
I have IIS on xp with asp available. the user wont have e-mail accounts availble so message must be sent via the form.

any ideas how i go abt doing this ?

cheers
 
Hi, well I got the email submition working using asp.net mailmessage() command.

now I realised I need the user to enter details such as testscript, test number,screen ID etc, basically its a customer form I have already designed.

But how do I submit this form to email via asp.net ?

Regards.
 
happytechie said:
just set the correct properties in the instance of the mailmessage Class that you've just created with the values from the form....

http://msdn.microsoft.com/library/d...l/frlrfsystemwebmailmailmessageclasstopic.asp

HT

not sure exactly what you mean, but if its what i think i tried then i cant because the mailmessage will only recognise certain typres such as subject, body, to , from..... i tried adding my own in but it *** just error

eg

Code:
Compiler Error Message: BC30456: 'Screen' is not a member of 'System.Web.Mail.MailMessage'.

Source Error:

 

Line 38: mailObj.Subject = MsgSubject.Text
Line 39: mailObj.Body = MsgBody.Text
Line 40: mailObj.Screen = MsgScreen.Text
Line 41: 
Line 42:
 
assuming mailObj is of type System.Web.Mail.MailMessage

then it should be as described in the documentation link that I posted?

Subject and Body are fine but it doesn't have a property called Screen, and what on earth did you think that a screen property for a mail message would be for , it makes no logical sense at all? Have you read the documentation for the MailMessage Class the error message itself is fairly easy to understand?

HT
 
yes mailobj is declared: Dim mailObj AS new MailMessage

yeah I tried to add screen as my own property because I need the user to specifially enter certain other attributes such as Screen Number, test number, and plenty more.

I have a form that requres various text to be entered in textboxes, and checkboxes selected that applies to the user filling in the form. I then need to get this all sent via email. How to do this via MailMessage() I dnt know because afaik u can write a message in using the body attribute of MailMessage() which I can get it to send fine using simple multiline text.

But how to send my custom form via MailMessage() I dnt understand :S

I never thought something relatively simple could be so complicated :(
 
You can't just add new properties to an existing object. if you want to add extra properties then you will need to define your own class that extends mailmessage. I haven't checked but make sure mailmessage isn't sealed before you try that. If it isn't then extend it and add the values of the properties to the body of the message before you send it.

If you can already put text into the mailmessage's Body property and send that then you are 99% of the way there with a quick and dirty solution. why not do something like this ( sorry it's in C# VB hurts my head but you'll figure it out ;) )

String body = mailObj .body;
body = body + "Screen: " + MsgScreen.Text + "\n";
body = body + "test Number: " + MsgNumber.text + "\n";
...
MailMessage.Body = body;

now you have all of the text you need in the body of your E-mail.

it would be much faster to use a stringbuilder rather than just concatenating strings like I have done in my example above.

Once you have constructed the mailMessage class with the values that you need it is sent via the asmtpmail class http://msdn.microsoft.com/library/d...html/frlrfsystemwebmailsmtpmailclasstopic.asp

Please not that I have NEVER done any of this all I have done if follow the link in the documentation that I posted you a link to earlier.

PLEASE READ THE MSDN LIBRARY
 
Back
Top Bottom