John Doe
John Doe

Reputation: 2060

Form in C#/Sharepoint

I am trying to create a form in Sharepoint using C#. I don't know C# that well and that is where my error is occurring. I want the information to be emailed to the address on submission. Here is the code I have for my tizagEmailForm.html...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 2</title>
</head>

<body>

<form method="POST" action="tizagEmail.aspx">
To <input type="text" name="To"/> <br />
From <input type="text" name="From"/> <br />
Subject <input type="text" name="Subject"/> <br />
Body <textarea name="Body" rows="5" cols="20" wrap="physical" > 
</textarea>
<input type="submit" />
</form>

</body>
</html>

And here is the code I have for my tizagEmail.aspx...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ Page Language="C#" 

'Sends an email
Dim mail
Set mail = Server.CreateObject("CDO.Message")
mail.To = Request.Form("To")
mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")
mail.TextBody = Request.Form("Body")
mail.Send()
Response.Write("Mail Sent!")
'Destroy the mail object!
Set mail = nothing

%>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<meta name="WebPartPageExpansion" content="full" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 2</title>
</head>

<body>

<form id="form1" runat="server">
</form>

</body>
</html>

If someone could help me I would very much appreciate it.

Live long and prosper.

Upvotes: 1

Views: 1499

Answers (2)

user4531
user4531

Reputation: 2565

I think the best way to achieve what you want to do is to use a WebPart.
You should look at this tutorial about how to create a contact Form Web Part for SharePoint.

Upvotes: 2

Gribbler
Gribbler

Reputation: 434

It looks like you've told the page to use C#, but Dim is a VB keyword. So it looks like you've mixed up your languages.

You also seem to have mixed up Classic ASP and ASP.NET.

Classic ASP uses VB, ASP.NET uses C# and VB.NET. Classis and .NET are very different.

Sending via ASP.NET http://forums.asp.net/t/971802.aspx

Sending via classic asp: http://forums.iis.net/t/1144383.aspx

Upvotes: 2

Related Questions