<%@dotnet.itags.org. Page Language="vb" %>
<%@dotnet.itags.org. Register TagPrefix="nav" TagName="bar" src="http://pics.10026.com/?src=navigation.ascx" %>
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %
<script language="vb" debug="true"
Sub btnGo_Click(sender As Object, e As EventArgs)LabelSent.text = "about to try sending mail"
Dim from as String = "neil@dotnet.itags.org.domain.com";
Dim to as String = "neil@dotnet.itags.org.domain.com";
Dim subject as String = "subject text";
Dim Body as String = "body text";
Dim from as String = "neil@dotnet.itags.org.domain.com";sendMail(to, from, subject, Body, false, "mail.domain.com")
End Sub
Public Function SendMail(ByVal [To] As String, _
ByVal From As String, ByVal Subject As String, _
ByVal Body As String, ByVal IsHTML As Boolean, _
Optional ByVal SmtpServer As String = "mail.yuzumedia.com") As Boolean
' Sends a mail message using the specified details
' - returns a False if delivery failsTry
Dim objMsg As New System.Web.Mail.MailMessage()
SendMail = True
With objMsg
.To = [To]
.From = From
.Subject = Subject
.Body = Body
' .BodyFormat specifies whether the Body is
' in plain text or HTML format
.BodyFormat = IIf(IsHTML = True, _
System.Web.Mail.MailFormat.Html, _
System.Web.Mail.MailFormat.Text)
End With
System.Web.Mail.SmtpMail.SmtpServer = SmtpServer
System.Web.Mail.SmtpMail.Send(objMsg)
Catch
SendMail = False
End Try
End Function</script
-->the button
You can specify an event handler for the button:
<asp:Button ID="btnGo" Text="Go!" CommandName="btnGo_Click" runat="server" />
<asp:Button ID="btnGo" Text="Go!" OnClick="btnGo_Click" runat="server" /
FYI:http://asp.net/webmatrix/guidedtour/section13/createemailform.aspx
Regards,
thanks,
I just got this instead:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'btnGo_Click' is not a member of 'ASP.enquiry4_aspx'.
I'm still getting that error, I've not had time to follow the tutorial there properly, but can someone tell me what I'm doing to get that compilation error?
I think (and I could be talking out my ass here) that you need a Handles statement for the click event:
Sub btnGo_Click(sender As Object, e As EventArgs)Handles btnGo.Click
just tried that now,
unfortunately it makes no difference, it still just gives me the following msg
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'btnGo_Click' is not a member of 'ASP.enquiry4_aspx'.
Can you post the relevant code again?
If you are using VS.NET go to design view and double click your button.
It will create method to handle click event of your button. Just type your code in, recompile your project and it should work.
Its pretty much the same as before except forHandles btnGo.Click
<%@. Page Language="vb" %>
<%@. Register TagPrefix="nav" TagName="bar" src="http://pics.10026.com/?src=navigation.ascx" %>
<%@. Import Namespace="System.Web.Mail" %
<script language="vb" debug="true"
Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.ClickDim from as String = "neil@.mydomain.com";
Dim to as String = "neil@.mydomain.com";
Dim subject as String = "subject text";
Dim Body as String = "body text";
Dim from as String = "neil@.mydomain.com";sendMail(to, from, subject, Body, false, "mail.mydomain.com")
End Sub
Public Function SendMail(ByVal [To] As String, _
ByVal From As String, ByVal Subject As String, _
ByVal Body As String, ByVal IsHTML As Boolean, _
Optional ByVal SmtpServer As String = "mail.mydomain.com") As Boolean
' Sends a mail message using the specified details
' - returns a False if delivery failsTry
Dim objMsg As New System.Web.Mail.MailMessage()
SendMail = True
With objMsg
.To = [To]
.From = From
.Subject = Subject
.Body = Body
' .BodyFormat specifies whether the Body is
' in plain text or HTML format
.BodyFormat = IIf(IsHTML = True, _
System.Web.Mail.MailFormat.Html, _
System.Web.Mail.MailFormat.Text)
End With
System.Web.Mail.SmtpMail.SmtpServer = SmtpServer
System.Web.Mail.SmtpMail.Send(objMsg)
Catch
SendMail = False
End Try
End Function</script
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML xmlns:o xmlns:st1>
<HEAD>
<title>Milano - Contact</title>
<link href="http://links.10026.com/?link=milano.css" rel="stylesheet" type="text/css">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD>
<BODY bgColor="#ffffff" MS_POSITIONING="GridLayout">
<form id="Gallery" method="post" runat="server" action="mailto:neil@.mydomain.com">
<TABLE cellSpacing="0" cellPadding="0" width="691" align="center" border="0">
<TR>
<TD colspan="3">
<div align="right"><nav:bar id=myBar runat=server />
</div></TD>
</TR>
<TR>
<TD style="HEIGHT: 15px" colSpan="2"> </TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="169" alt="" src="http://pics.10026.com/?src=images/studio_mainbar.jpg" width="691"></TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="10" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="691"></TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="23" alt="" src="http://pics.10026.com/?src=images/contact_bar.gif" width="691"></TD>
</TR>
<TR>
<TD colSpan="3"><IMG height="10" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="691"></TD>
</TR>
<TR>
<TD colSpan="3">
<table id="page_content" cellPadding="10" width="100%" border="0">
<tr>
<td style="WIDTH: 349px" vAlign="top" align="left" colSpan="2" rowSpan="2" width="349"
class="maintext">
<div align="left" class="maintext">
<p>Please
email any enquiries to enquiries@.studioglasgow.co.uk</p>
<p>Phone - 0141 332 1444</p>
<p>STUDIO - 98 Sauchiehall Street -
Glasgow</p>
</div> </td>
<TD vAlign="top" align="center" width="323" colSpan="2"><P class="MsoNormal">
</P>
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label1" runat="server" CssClass="maintext">name</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label2" runat="server" CssClass="maintext">tel</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxTel" runat="server"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label3" runat="server" CssClass="maintext">email</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label4" runat="server"
CssClass="maintext">address</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxAddress" runat="server" Height="56px" TextMode="MultiLine"></asp:TextBox>
</span></td>
</tr>
<tr>
<td><span class="MsoNormal">
<asp:Label ID="Label5" runat="server"
CssClass="maintext">enquiry</asp:Label>
</span></td>
<td><span class="MsoNormal">
<asp:TextBox ID="TextBoxEnquiry" runat="server" Width="290" Height="152px" TextMode="MultiLine"></asp:TextBox>
</span></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit">
<asp:Button ID="btnGo" Text="Go!" OnClick="btnGo_Click" CommandName="btnGo_Click" runat="server" /></td>
</tr>
</table>
</TD>
</tr>
</table>
</TD>
</TR>
<TR>
<TD><IMG height="1" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="316"></TD>
<TD style="WIDTH: 120px"><IMG height="1" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="196"></TD>
<TD><IMG height="1" alt="" src="http://pics.10026.com/?src=images/pixel.gif" width="179"></TD>
</TR>
</TABLE>
</form>
</BODY>
</HTML
I've not got VS studio,
got webmatrix though, but have hardly used it, will that do the same?
Hey, the only problem I could find was that the BtnGo_Click method itself is a little weird. Semi colons at the end of lines? Double declaration of from? Keywords used as variable names ('To' for example, which is why it's in [] in the function call, but I don't believe this is valid in VB).
I use VS, so all of these problems were caught before building, but I know nothing about WebMatrix. My BtnGo event:
Sub btnGo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGo.Click
Dim sfrom As String = "neil@.mydomain.com"
Dim sto As String = "neil@.mydomain.com"
Dim ssubject As String = "subject text"
Dim sBody As String = "body text"SendMail(sto, sfrom, ssubject, sBody, False, "mail.mydomain.com")
End Sub
I'm not having much luck with this either.....
<b>
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30188: Declaration expected.
Source Error:
Line 7: 'create new email msg
Line 8: Dim newMail As new MailMessage
Line 9: newMail.From = "neil@.mydomain.com"
Line 10: newMail.To = "neil@.mydomain.com"
Line 11: newMail.Subject = "myMail"
Source File: c:\inetpub\wwwroot\milanos\myMail.aspx Line: 9
<b/
<%@. Import Namespace="system.Web.Mail" %>
<html>
<head>
<script language="vb" runat="server"
'create new email msg
Dim newMail As new MailMessage
newMail.From = "neil@.mydomain.com"
newMail.To = "neil@.mydomain.com"
newMail.Subject = "myMail"
newMail.Body = "myMail :: body"SmtpMail.Send(newMail)
End Sub</script
<title>Untitled Document</title>
</head>
<body
</body>
</html
@.colt
i followed the steps in the guide and its all kosher now :)
0 comments:
Post a Comment