Attachments.(Function(a) a.ContentStream).OfType(Of System.IO.FileStream)().(Function(fs) fs.Name)ĮrrorMessage = "CDO SEND ERROR: " & ex.Message BccĬDOMessage.BCC = CDOMessage.BCC & ToAddress.DisplayName & " "ĭim FileNames =. CCĬDOMessage.CC = CDOMessage.CC & ToAddress.DisplayName & " "įor Each ToAddress As In. ToĬDOMessage.To = CDOMessage.To & ToAddress.DisplayName & " "įor Each ToAddress As In. From.DisplayName & " "įor Each ToAddress As In. If Recipient.Address = FailedAddress Thenĭim CDOMessage As Object = CreateObject("CDO.Message")ĬDOMessage.From =. If TypeOf (OriginalException) Is Thenĭim SMTPEX As = CType(OriginalException, )ĭim FailedAddresses As New List(Of String)ĭim NewTo As New List(Of )ĭim NewCC As New List(Of )ĭim NewBCC As New List(Of )įor Each InnerEx As In SMTPEX.InnerExceptionsįailedAddresses.Add(("", ""))įor Each Recipient As In OriginalMessage.Toįor Each KeepAddress As String In FailedAddressesįor Each Recipient As In NewToįor Each Recipient As In OriginalMessage.CCįor Each Recipient As In NewCCįor Each Recipient As In OriginalMessage.Bccįor Each Recipient As In NewBCCĮlseIf TypeOf (OriginalException) Is Thenĭim SMTPEX As SmtpFailedRecipientException = CType(OriginalException, SmtpFailedRecipientException)ĭim FailedAddress As String = ("", "") Public Function SendCDOEmail(ByRef OriginalMessage As, ByVal OriginalException As Exception) As Stringĭim ErrorMessage As String = String.Empty
The SendCDOEmail function is as follows: Option Strict Off The MailServer.Send method works without error if all of the recipients are within the same (my) domain, but will throw an SmtpFailedRecipientException or SmtpFailedRecipientsException for any recipient address with a different domain. MessageBox.Show(ExceptionMessage, "NOTIFICATION E-MAIL FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error) If Not String.IsNullOrEmpty(CDOError) Thenĭim ExceptionMessage As String = ".NET SEND ERROR: " & ex.Message & vbCrLfĮxceptionMessage += ex.InnerException.Message & vbCrLf
#Outbox office 365 code#
My code for sending a message is pretty standard (obviously obfuscated a bit for posting), but I've had to include a separate function for sending the message via CDO if it fails: Private Function SendFTPSuccessMail() As Booleanĭim Email As New ĭim MailServer As New (".com")īodyText = "SOME TEXT FOR THE E-MAIL MESSAGE"ĭim CDOError As String = SendCDOEmail(Email, ex) I've found a workaround, but I'm wondering if I'm simply missing something in the configuration that might be causing the issues. Ever since then, I've encountered problems sending e-mail messages to people outside of our organization from my VB.NET applications.
Our company recently migrated from an on-premise mail server (CommunigatePro) to hosted mail through our Office 365 subscription.