SMTP Email not reaching all recipients

Discussion in 'ASP.NET / ASP.NET Core' started by blueprintpm, Feb 23, 2016.

  1. This code started having problems last week - after about 2 years of no problem, 2 recipients out of 5 aren't receiving the email. They are on 2 different domains, so it's mysterious. Anyone have any suggestions on what to try? Thanks in advance for any help!!

    Code:

    Try
    Dim strFrom = "[email protected]", txtFileAttach AsString = ""

    txtFileAttach = "Weekly_BU_Report_" & Yr & "_" & Mo & "_Gen_" & FormatDateTime(Now(), DateFormat.ShortDate) & ".xls"
    '*** pull 'to' recipients from database
    Dim strTo = Util.GetReportEmails("Weekly_BU_Report", "RecipientsTO")

    Dim MailMsg AsNewMailMessage(NewMailAddress(strFrom.Trim()), NewMailAddress(strTo))

    MailMsg.BodyEncoding = Encoding.Default

    '*** Add "TO" recipients from tbReportUser table
    MailMsg.To.Add(Util.GetReportEmails("Weekly_BU_Report", "RecipientsAddTO"))

    '*** Add "BCC" recipients from tbReportUser table
    MailMsg.Bcc.Add(Util.GetReportEmails("Weekly_BU_Report", "RecipientsBCC"))

    MailMsg.Subject = "Weekly Business Unit Report"

    MailMsg.Body = "Please see attached file. Please contact me at [email protected] to discontinue receipt of this report. "

    Dim stream AsFileStream = File.OpenRead(FileName)

    Dim attachment AsAttachment = NewAttachment(stream, txtFileAttach)


    MailMsg.Attachments.Add(attachment)

    MailMsg.Priority = MailPriority.High

    MailMsg.IsBodyHtml = True

    'Smtpclient to send the mail message

    Dim SmtpMail AsNewSmtpClient

    SmtpMail.Host = "localhost"

    SmtpMail.Send(MailMsg)

    Catch ex AsException

    '*** I call utility that emails error information to me. I am not getting any errors.

    EndTry
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    mjp likes this.

Share This Page