locked
sending email in asp and .NET RRS feed

  • Question

  • User-1622147890 posted
    Following code in vb.net is working:

    Dim msg As New MailMessage()
    msg.To.Add(New MailAddress("someone@mycompany.com"))
    msg.Subject = strSubject$
    msg.From = New MailAddress("myname@mycompany.com")

    msg.Body = strBody$

    Dim auth As System.Net.NetworkCredential = New System.Net.NetworkCredential("myname@mycompany.com", "password")

    Dim client As New SmtpClient()
    client.Host = "smtp.exg5.exghost.com"
    client.Port = 2525
    client.UseDefaultCredentials = False
    client.Credentials = auth
    client.EnableSsl = True
    client.DeliveryMethod = SmtpDeliveryMethod.Network
    client.Send(msg)


    But using same credentials following code in asp is not working:

    Dim cdoConfig, mail, sch

    Set cdoConfig = CreateObject("CDO.Configuration")
    Set mail = CreateObject("CDO.Message")

    sch = "http://schemas.microsoft.com/cdo/configuration/"
    with cdoConfig.fields
    .item(sch + "sendusing").value = 2
    .item(sch + "smtpserver").value = "smtp.exg5.exghost.com"
    .item(sch + "smtpserverport").value = 2525
    .item(sch + "smtpusessl").value = true
    .item(sch + "smtpconnectiontimeout").value = 60
    .item(sch + "smtpauthenticate").value = 1
    .item(sch + "sendusername").value = "myname@mycompany.com"
    .item(sch + "sendpassword").value = "password"
    .Update()
    End With

    Set mail.Configuration = cdoConfig
    mail.to = "someone@mycompany.com"
    mail.From = "myname@mycompany.com"
    mail.TextBody = strBody
    mail.Subject = strSubject
    mail.Send

    error message:
    Error Type:
    CDO.Message.1 (0x80040213)
    The transport failed to connect to the server.
    /EmailQuote.asp, line 225

    Any help would be appreciated.
    Saturday, October 30, 2010 9:18 AM

All replies