Quantcast
Viewing latest article 25
Browse Latest Browse All 51036

sending email thought MS365

Hi
we just upgraded to office 365.
One of the apps I created was sending emails with no problem.
New I cant seam to send any emails through MS365.
The error I receive is in the attachment.
This is a test code I have tried.

Private Sub newmail()
        Dim msg As MailMessage = New MailMessage()
        msg.[To].Add(New MailAddress("you@domain.com"))
        msg.From = New MailAddress("me@domain.com")
        msg.Subject = "This is a Test Mail"
        msg.Body = "This is a test message using Exchange OnLine"
        msg.IsBodyHtml = True
        Dim client As SmtpClient = New SmtpClient()
        client.UseDefaultCredentials = False
        client.Credentials = New System.Net.NetworkCredential("me@domain.com", "password")
        client.Port = 587
        client.Host = "smtp.office365.com"
        client.DeliveryMethod = SmtpDeliveryMethod.Network
        client.EnableSsl = True
        Try
            client.Send(msg)
            MessageBox.Show("Message Sent Succesfully")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub


Thanks

Viewing latest article 25
Browse Latest Browse All 51036

Trending Articles