0

I am trying to send a mail using Net.Mail.

The error message that I get in the line

"nClient.Send(nMail)"

is:

"Could not send mail to all recipients." 

I don't know where I did something wrong.

Does anybody see my mistake?

Thank you very much!

        Dim sSubject As String = "Response to your order"
        Dim sBody As String = "Dear Sir or Madame, here is your invoice."

        Dim sTo As String = "customer@customers.com"
        Dim sFrom As String = "office@mycompany.com"
        Dim sFromFriendly As String = "My super nice office team"

        Dim nAtt As Net.Mail.Attachment = New Net.Mail.Attachment("C:\somepdf.pdf")

        Dim nMail As New Net.Mail.MailMessage(sFrom, sTo, sSubject, sBody)
        With nMail
            .IsBodyHtml = False
            .Bcc.Add(sFrom) 'Send a BCC to myself
            .From = New MailAddress(sFrom, sFromFriendly) 'Add my nice name moniker
            .Attachments.Add(nAtt) 'Add the pdf file
        End With

        Dim nCred As New System.Net.NetworkCredential
        With nCred
            .UserName = "myusername"
            .Password = "mypassword"
        End With

        Dim nClient As New SmtpClient()
        With nClient
            .Host = "mywebhost"
            .Port = 587
            .UseDefaultCredentials = False
            .Credentials = nCred
        End With

        nClient.Send(nMail)

        nMail.Dispose()
Bjørn-Roger Kringsjå
  • 9,849
  • 6
  • 36
  • 64
tmighty
  • 10,734
  • 21
  • 104
  • 218
  • Your code seems correct. The error usually has an error code, which gives more information regarding what went wrong. Perhaps this error code is in the InnerException – Tasos K. Mar 03 '14 at 16:27
  • 1
    The error was raised by my webhost because the BCC address did not exist. – tmighty Mar 03 '14 at 16:44

0 Answers0