1

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.

4
  • 1
    Server Error in '/' Application. -------------------------------------------------------------------------------- Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The server block is not well formed. Source Error: Line 1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Line 2: <%@ Page Language="C#" Line 3: Line 4: 'Sends an email Commented Jun 27, 2012 at 16:15
  • 1
    the way you are trying to achieve your requirement seems odd. When working with SharePoint, we use to build webpart, infopath forms or simple application page. Why did you create both an html page and a aspx page, disconnected from the whole SharePoint framework (no master page, etc...) ? Commented Jun 27, 2012 at 16:16
  • 1
    You put Page Language="C#" and your code is in VB. Commented Jun 27, 2012 at 16:16
  • 1
    I think I just have the syntax in my C# page messed up, but I can't figure out how. Commented Jun 27, 2012 at 16:16

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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

3 Comments

How would I fix it? Is it something simple?
@user1460876 <%@ Page Language="VB"
Now it is displaying this message...Code blocks are not allowed in this file.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.