sending email using asp.net and vb.net?
Code:
<%@ Import Namespace="System.Net.Mail" %>
<script runat="server">
Protected Sub Sendmail_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim myMessage As MailMessage
Dim mySmtpClient As SmtpClient
Dim strfromname As String
Dim strfrom As String
Dim strto As String
strto = "[email protected]"
strfrom = txtFromEmail.Text
strfromname = txtFromName.Text
If Page.IsValid() Then
myMessage = New MailMessage
myMessage.From = New MailAddress(strfrom, strfromname & "<" & strfrom & ">")
myMessage.To.Add(New MailAddress(strto))
myMessage.Subject = txtsubject.Text
myMessage.Body = txtMessage.Text
mySmtpClient = New SmtpClient("smtp.mydomain.com", 25)
mySmtpClient.UseDefaultCredentials = False
mySmtpClient.EnableSsl = True
mySmtpClient.Credentials = New System.Net.NetworkCredential("[email protected]", "mypassword")
'mySmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
mySmtpClient.Send(myMessage)
lblMessageSent.Text = "Thank you.We have received your message."
lblMessageSent.ForeColor = Drawing.Color.BlueViolet
End If
txtFromEmail.Text = ""
txtFromName.Text = ""
txtMessage.Text = ""
txtsubject.Text = ""
End Sub
</script>
telnet smtp.mydomain.com 25 works fine, but i couldnot send email . please help me here is the error.
No connection could be made because the target machine actively refused it mydomain Ip:25
help me please
Re: sending email using asp.net and vb.net?
Are you running this from your machine? Or from the Server?
Also when you issue the telnet command, is it from your machine or from the server where the code is running?
And when you login using telnet, are you logging in as yourself or as the same credentials as the script?
-tg
Re: sending email using asp.net and vb.net?
Moved to the ASP.Net forum.
Re: sending email using asp.net and vb.net?
my domain is somewhere else hosted.. then i try telnet from my computer to the remote hosted domain.. telnet works fine,
but i could not send email
Re: sending email using asp.net and vb.net?
Hello,
You have the EnableSsl property set to true, which would suggest that you should be using something other than port 25.
Gary