You are Here:
FAQ
Scripting and Programming Languages
ASP.NET
Article #7
Sending e-mails using ASP.Net Microsoft® Packages with .NET/MSSQL Only!
This includes: 1&1 MS Business 1&1 MS DeveloperThis DOES NOT include: 1&1 MS Beginner 1&1 MS HomeIn order to be able to send e-mail using ASP.net, you have to use the name space System.Web.Mail and the appropriate class MailMessage The following is a sample:
<% @Import Namespace="System.Web.Mail" %>
<script language="vb" runat="server">
Sub contactUS_Click(sender as Object, e as EventArgs)
'Create an instance of the MailMessage class
Dim objMM as New MailMessage()
objMM.To = "info@1and1.com"
objMM.From = email.Text
'If you want to CC this e-mail to someone else
'objMM.Cc = "support@1and1.com"
'e-mail format. Can be Text or Html
objMM.BodyFormat = MailFormat.Text
'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.Normal
'Set the subject
objMM.Subject = "1&1 Contact US"
'Set the body
objMM.Body = message.Text
'Smtp Server
SmtpMail.SmtpServer = "mrelay.perfora.net"
'Send the message
SmtpMail.Send(objMM)
panelSendEmail.Visible = false
panelMailSent.Visible = true
End Sub
</script>
<html>
<body>
<asp:panel id="panelSendEmail" runat="server">
<form runat="server">
<h2>CONTACT US FORM</h2>
<b>Your Name:</b>
<asp:textbox id="name" runat="server" />
<br>
<b>Your Email Address:</b>
<asp:textbox id="email" runat="server" />
<p>
<b>Your Message:</b><br>
<asp:textbox id="message" TextMode="MultiLine"
Columns="40" Rows="10" runat="server" />
<p>
<asp:button runat="server" id="contact_us" Text="Contact" OnClick="contactUS_Click" />
</form>
</asp:panel>
<asp:panel id="panelMailSent" runat="server" Visible="False">
An e-mail has been sent. We will contact you soon!
</asp:panel>
</body>
</html>
Disclaimer: 1&1 provides the scripts and related information on this page as a courtesy, subject to 1&1's General Terms and Conditions of Service (the "GT&C"). As set forth in more detail in the GT&C, the scripts and information are provided "as-is", without any warranty, and 1&1 is not liable for any damages resulting from your use of the scripts or information. |
© 2008 1&1 Internet Inc - About 1&1 Internet