• VB.Net email

  • Started by ranacsteve,
  • at 05/29/2018, 13:07pm

ranacsteve

Male, 63yo

Indianapolis, IN

  • Member
  • Offline
  • Threads
    1
  • Posts
    3
  • Likes
    0
  • Follows
    0
  • Followers
    0

at 05/29/2018, 13:07pm

I am writing an application in Visual Basic 2010 to send email through our mail.activesend.com account using the credentials that we use to access the account from Outlook.
When I attempt to send a test email, I get the error: "Email Failed. Mailbox Unavailable. The server response was: Authentication is required for relay"
Is there a way I can send emails via this method?
Thank you.

Troy

Male, 51yo

Nashville, TN USA

  • Administrator
  • Offline
  • Threads
    3
  • Posts
    4
  • Likes
    5
  • Follows
    0
  • Followers
    0

at 06/10/2018, 23:45pm

at 05/29/2018, 13:03pm ranacsteve
I am writing an application in Visual Basic 2010 to send email through our mail.activesend.com account using the credentials that we use to access the account from Outlook.
When I attempt to send a test email, I get the error: "Email Failed. Mailbox Unavailable. The server response was: Authentication is required for relay"
Is there a way I can send emails via this method?
Thank you.
Sorry for the delay! These forums are relatively new and haven't even been announced, so they're not in much use, and I have yet to develop a habit of checking them. I'll try to do better!
 
You really shouldn't have any trouble sending email out this way provided that smtp authentication is done properly. From the error is sort of seems like maybe that isn't the case in your code. If you want to post some of the code with important authentication redacted I can look at it. We're not a .net shop though so I can't promise I can help troubleshoot it. However, I did use to code quite a bit in vb back in the day (A major hotel chain had the largest VB development project underway at the time and I was a consultant on it) so it's possible I might be able to help.

ranacsteve

Male, 63yo

Indianapolis, IN

  • Member
  • Offline
  • Threads
    1
  • Posts
    3
  • Likes
    0
  • Follows
    0
  • Followers
    0

at 06/11/2018, 07:30am

Here is the sub used to send an email and thank you for the assistance! Let me know if you need any clarification.
Steve
 
Dim aryAddresses() As String
Dim smtpServer As New SmtpClient(smtpserveraddress)
Dim mail As New MailMessage
mail.From = New MailAddress(retaddr)
    If txtTo.Text <> "" Then
        aryAddresses = fnBuildAddressArray("To")
        For i As Integer = 0 To aryAddresses.Length - 1
            mail.To.Add(aryAddresses(i))
        Next
    End If
    If txtCc.Text <> "" Then
        aryAddresses = Nothing
        aryAddresses = fnBuildAddressArray("cc")
        For i As Integer = 0 To aryAddresses.Length - 1
            mail.CC.Add(aryAddresses(i))
        Next
    End If
    If txtBcc.Text <> "" Then
        aryAddresses = Nothing
        aryAddresses = fnBuildAddressArray("bc")
        For i As Integer = 0 To aryAddresses.Length - 1
            mail.Bcc.Add(aryAddresses(i))
        Next
    End If
    mail.Subject = txtSubject.Text
    mail.Body = txtBody.Text & vbCrLf
    If chkHiPriority.Checked = True Then
        mail.Priority = MailPriority.High
    Else
        mail.Priority = MailPriority.Normal
    End If
    smtpServer.Port = 25
'I had tried .EnableSsl both True and False
    smtpServer.EnableSsl = False
    'password is loaded in code previous to this and stored in "password" variable
    smtpServer.Credentials = New NetworkCredential("support@ranac.com", password, "ranac.com")
    Try
        smtpServer.Send(mail)
    Catch ex As Exception
        MessageBox.Show("Email Failed" & vbCrLf & ex.Message, strMsgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End Try
    MessageBox.Show("Email Sent", strMsgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information)

Edited by: ranacsteve at 06/11/2018, 07:33am, Reason: Left a line out

ranacsteve

Male, 63yo

Indianapolis, IN

  • Member
  • Offline
  • Threads
    1
  • Posts
    3
  • Likes
    0
  • Follows
    0
  • Followers
    0

at 07/10/2018, 07:12am

Resolved.
Problem was so simple I'm embarrased to post it, let's just say there were problems with the format of my host and password strings.