Results 1 to 4 of 4

Thread: Email Client to Client

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    116

    Question Email Client to Client

    I am trying to code an event in a vb.net webform to enable two client users to email each other.
    The Code I have below is wrong and I think the problem lies in the SmtpServer bit.
    Can someone advise me on how to do this?

    Thanks alot

    Code:
            Dim objEmail As New MailMessage()
            objEmail.To = "[email protected]"
            objEmail.From = "[email protected]"
            
            objEmail.Subject = "Test Email"
            objEmail.Body = "Test Email 2"
            SmtpMail.SmtpServer = "sendmail.mywebsitehost.com"
    
            Try
                SmtpMail.Send(objEmail)
                Response.Write("Your E-mail has been sent sucessfully -" & _
                               "Thank You")
    
            Catch exc As Exception
                Response.Write("Send failure: " + exc.ToString())
            End Try

  2. #2
    The code actually looks correct to me at a glance. Are you sure the SMTP server you are using allows relay without authentication? The problem might not be the code, but rather the way the local SMTP relay is configured.

    Also if you are sending from an email address that a local relay doesn't recognize, this can cause problems too.

    If your testing the page on your local dev server, an outbound filter or firewall might also affect it...
    Developer Web Hosting - ASP.NET & PHP
    www.datahostingcenter.com
    15% OFF HOSTING Coupon for Forum Members - Enter:
    vbforums

  3. #3
    One other thing I forgot is:

    Try specifying explicitly the encoding type as such:
    myMail.BodyEncoding = System.Text.Encoding.ASCII

    I really don't think your problem is the code though, sounds like an SMTP authentication or relay problem...
    Developer Web Hosting - ASP.NET & PHP
    www.datahostingcenter.com
    15% OFF HOSTING Coupon for Forum Members - Enter:
    vbforums

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    116

    Thumbs up Got It!

    Thank you for the reply.
    Like you said, the code was ok.
    The problem was within my email settings on the webserver - I didnt set it up correctly.

    All Ok now!

    Thanks again

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