vb.netexchange-serversmtpclientmailmessage

SmtpClient MailMessage ignoring Server Mail Flow Rule


I have an Simple Application that Sends and email as Follows:

  Private Sub sendEmail()

            'create the mail message
            Dim mail As New MailMessage()

            'set the addresses
            mail.From = New MailAddress(cmbFrom.Selected.Value)

            mail.[To].Add(cmbTo.Selected.Value)
               
            mail.IsBodyHtml = True

            'set the content
            mail.Subject = getSubject()
            mail.Body = getBody()

            If cmbSubj.Selected.Description = "Confirmation" Then
                mail.Headers.Add("Disposition-Notification-To", cmbFrom.Selected.Value)
            End If


            'set the server             
            Dim smtp As New SmtpClient("Mail.MyDomain.Co.Uk")

            'smtp.UseDefaultCredentials = True

            smtp.Credentials = CredentialCache.DefaultNetworkCredentials

            'send the message
            Try
                smtp.Send(mail)
                Application.SBO_Application.MessageBox("Your Email has been sent sucessfully - Thank You")
                oForm.Close()
            Catch exc As Exception
                Application.SBO_Application.MessageBox("Send failure: " & exc.ToString())
            End Try   


        End Sub

and this Exchange Server Mail Flow Rule: Mail Flow Rule

Unfortunately the mail flow rule is not applying to messages,

How can i ensure this Mail Flow rule applies to the App based Emails and why Has it been ignored so far?


Solution

  • Changing the Mail Flow Rule Resolved the issue, However the question of why the rules were missed when using the smtpClient Remains.

    To resolve the rule was changed to "The Sender Address Matches..." and the Domain name.

    mail flow rule 2