Cannot get email function to work?

Discussion in 'Email' started by longmatch, Aug 4, 2013.

  1. Hi,
    I tried to use the following code to send email either from local host or on the Winhost server, unfortunately neither worked. I have double checked that the email address and password I used were correct. The error I got from localhost was 'Failure to sending email'. I did change the mail server in Manage MX record server to my server - mail.xxxxxx.info. It still did not work. I think something must be missing from my part. What else do I need to do to get the email working? The server configuration?

    Thanks

    Longmatch

    _________________________________________________________________________
    Dim strFrom = "[email protected]"
    Dim strTo = "[email protected]"
    Dim MailMsg AsNew MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
    MailMsg.BodyEncoding = Encoding.Default
    MailMsg.Subject = "This is a test"
    MailMsg.Body = "This is a sample message using SMTP authentication"
    MailMsg.Priority = MailPriority.High
    MailMsg.IsBodyHtml = True
    'Smtpclient to send the mail message
    Dim SmtpMail AsNew SmtpClient
    Dim basicAuthenticationInfo AsNew System.Net.NetworkCredential("[email protected]", "Password")
    SmtpMail.Host = "mail.xxxxxx.info"
    SmtpMail.UseDefaultCredentials = False
    SmtpMail.Credentials = basicAuthenticationInfo
    Try
    SmtpMail.Send(MailMsg)
    Catch ex As Exception
    lblMessage.Text = ex.Message
    Finally
    'lblMessage.Text = "not working"
    EndTry
    'lblMessage.Text = "Mail Sent"
     
  2. Tabitha

    Tabitha WinHost HBIC

    You can't use localhost on our servers; you have to use SMTP authentication, so that's why that didn't work. Have you changed your domain's nameservers to Winhost's, or are you using nameservers other than ours?
     
    Last edited by a moderator: Oct 14, 2015

Share This Page