Email is not getting sent to Office365 Email account

Does anyone know why my office365 email account works from inside our domain but does not work from our DMZ server?

Email sent from DMZ server to recipients with exchange account works fine.

However, users are not receiving emails sent to our office365 email account.

I have tried using my domain account but it does not work. I also tried using the DMZ server account but that does not send email either.

Any ideas?

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
        'Address of email sender
        Dim ccEmail As String = txtemail.Text

        'Create the msg object to be sent
        Dim msg As New MailMessage()

        'Add your email address to the recipients
        msg.[To].Add("office365emailaccount")
        'Configure the address we are sending the mail from
        Dim fromEmail As New MailAddress(ccEmail)
        msg.From = fromEmail
        'Append their name in the beginning of the subject
        msg.Subject = "Testing Office365 email account"

        'To embed image in email
        msg.Body = "If you receive this email, then office365 email account is working from DMZ server"
        '   msg.Attachments.Add(New Attachment(New MemoryStream(bytes), lblEmpName.Text & DateTime.Now.Ticks & ".pdf"))
        msg.IsBodyHtml = True

        'Configure an SmtpClient to send the mail.
        Dim client As New SmtpClient("xxx.xxx.x.xxx")   'Exhange IP Address
        client.Host = "smtp.office365.com"
        client.Credentials = New System.Net.NetworkCredential("dmzuser", "mydmzpassword")
        'client.DeliveryMethod = SmtpDeliveryMethod.Network
        client.EnableSsl = True
        client.Port = 25
        'Send the msg
        client.Send(msg)
        lblMsg.Text = "Success!"
    End Sub

Open in new window


Thanks in advance
LVL 29
sammySeltzerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
check your exchange transport logs
0
systechadminConsultantCommented:
if you are using 0365 SMTP server in your script, it wont work, you need to create relay account in 0365

Refer http://office365support.ca/smtp-relay-with-office-365/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sammySeltzerAuthor Commented:
Creating a relay on 0365 solved it for me.
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.