Results 1 to 5 of 5

Thread: sending email using asp.net and vb.net?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    208

    Red face 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

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: sending email using asp.net and vb.net?

    Moved to the ASP.Net forum.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    208

    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

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width