asp.net direct mailing

P

PuruCuhuco

can i directly mail to hotmail or yahoo acount with any asp.net code.


i have an example like above but i need smtp adress for hotmail,
i tried it for smtp.mail.yahoo.com but it didnt work and "authentication
required" error accured

here is the code:
<%@ Page Language="VB" ContentType="text/html" debug="true"
ResponseEncoding="iso-8859-1" %>
<%@Import Namespace="System.Web.Mail" %>
<script language="VBScript" runat="server">
' compile and send the email message
sub SendEmail(sender as Object, e As EventArgs)
' This script is the property of D2 Computing, please do not redistribute it
' Check www.d2computing.co.uk for more scripts
' *************************************************
' IMPORTANT - CHANGE THE TWO VARIABLES BELOW TO YOUR OWN EMAIL ADDRESS AND
SMTP SERVER ADDRESS
' *************************************************
' CHANGE THE BELOW TO THE ADDRESS YOU WISH THE EMAIL TO BE SENT TO
dim sendmessageto as string = "(e-mail address removed)"
' CHANGE THE BELOW TO YOUR SMTP SERVER ADDRESS, NORMALLY YOUR ISP'S SMTP
SERVER
dim smtpservername as string = "smtp.mail.hotmail.com"
dim HTMLmessage as string
HTMLmessage = "<html>"
HTMLmessage = HTMLmessage & "<head>"
HTMLmessage = HTMLmessage & "<meta http-equiv=""Content-Type"""
HTMLmessage = HTMLmessage & "content=""text/html; charset=iso-8859-1"">"
HTMLmessage = HTMLmessage & "<title>Mail from website contact</title>"
HTMLmessage = HTMLmessage & "</head>"
HTMLmessage = HTMLmessage & "<body bgcolor=""edefea"">"
HTMLmessage = HTMLmessage & "<font color=#000000 size=2 face=Verdana>"
HTMLmessage = HTMLmessage & "<b>Message sent from website contact
form:</b>"
HTMLmessage = HTMLmessage & "<p></p>"
HTMLmessage = HTMLmessage & "<b>Message from:</b> " & TxtUserName.Text
HTMLmessage = HTMLmessage & "<p></p>"
HTMLmessage = HTMLmessage & "<b>Users email:</b> " & TxtUserEmail.Text
HTMLmessage = HTMLmessage & "<p></p>"
HTMLmessage = HTMLmessage & "<b>Message text:</b> " & TxtComment.Text
HTMLmessage = HTMLmessage & "<p></p>"
HTMLmessage = HTMLmessage & "<b>Date/Time:</b> " & now()
HTMLmessage = HTMLmessage & "<p></p>"
HTMLmessage = HTMLmessage & "<b>Users IP address:</b> " &
Request.ServerVariables("REMOTE_ADDR")
HTMLmessage = HTMLmessage & "<p></p>"
HTMLmessage = HTMLmessage & "<b>****** END OF MESSAGE ******</b>"
HTMLmessage = HTMLmessage & "</font></body>"
HTMLmessage = HTMLmessage & "</html>"

Dim TheMessage as new Mailmessage
With TheMessage
..To = sendmessageto
..From = TxtUserEmail.Text
..Body = HTMLmessage
..Subject = "Message from D2 Computing web contact form"
..BodyFormat = MailFormat.Html
End With
SmtpMail.SmtpServer = smtpservername
Smtpmail.Send(TheMessage)
TxtComment.Enabled = "False"
TxtUserName.Enabled = "False"
TxtUserEmail.Enabled = "False"
TxtComment.Text = "***** Message Sent OK ***** Please follow the link below
to return to the main page"
TxtUserName.Text = "***** Message Sent OK *****"
TxtUserEmail.Text = "***** Message Sent OK *****"
BtnSendMail.Enabled = "False"
BtnSendMail.Text = "Message Sent !"
LblMailSent.visible = "True"
TheMessage = Nothing
end sub
</script>




<html>
<head>
<title>Contact us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="dotnetcontact.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="fmcontact" runat="server">
<p align="center"><img src="images/anonco.gif" width="371" height="74"></p>
<table width="550" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="186">Your Name:</td>
<td width="350"><asp:textbox AutoPostBack="false" ID="TxtUserName"
runat="server" TextMode="SingleLine" Width="250"/>
<asp:RequiredFieldValidator ID="ValUsername" runat="server"
ErrorMessage="Please supply your name."
ControlToValidate="TxtUserName" Text="*
Required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Your Email Address:</td>
<td><asp:textbox AutoPostBack="false" ID="TxtUserEmail"
runat="server" TextMode="SingleLine" Width="250"/>
<asp:RequiredFieldValidator ID="ValUserEmail" runat="server"
ErrorMessage="Please supply your email address."
ControlToValidate="TxtUserEmail" Text="*
Required"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="ValValidEmail" runat="server"
ValidationExpression="^[\w\-\.']+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*?\.[a-zA-Z]{2,4}$"
ErrorMessage="The email address must be a valid internet email address."
ControlToValidate="TxtUserEmail" Text="*
Valid?"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>Question/Comment:</td>
<td><asp:textbox AutoPostBack="false" ID="TxtComment" Rows="9"
runat="server" TextMode="MultiLine" Width="250" />
<asp:RequiredFieldValidator ID="ValUserComment" runat="server"
ErrorMessage="Please supply a question/comment."
ControlToValidate="TxtComment" Text="*
Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td> </td>
<td><asp:ValidationSummary
ID="valSum"
DisplayMode="BulletList"
runat="server"
HeaderText="Please check the following:"
Font-Name="verdana"
Font-Size="8"/>
</td>
</tr>
<tr>
<td colspan="2"><div align="center">
<asp:button ID="BtnSendMail" runat="server" Text="Send
Message" OnClick="SendEmail" />
</div></td>
</tr>
<tr>
<td colspan="2"><p align="center"><asp:label ID="LblMailSent"
runat="server" class="maillabel" Visible="False" Text="Your message was sent
sucessfully, click <a href=index.asp>here</a> to
return to the main page" /></p></td>
</tr>
</table>
<div align="center"></div>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top