system.net.mail is too slow

am using system.net.mail to send email as shown below, but its too slow. it takes about a minute to send, whats wrong with my code. Am calling the code below in backgroundworker_dowork.

[edit]: is there a faster alternative, maybe free or open source code

' send the email ' Dim smtp As SmtpClient = New SmtpClient() Dim mail As New MailMessage() Dim i As Long = 0 ' SMTP settings ' With smtp .Host = Trim$(sSMTP) .Port = Trim$(iPort) .UseDefaultCredentials = False .Credentials = New System.Net.NetworkCredential(sUserID, sPword) .EnableSsl = bSSL End With ' create the mail ' With mail If sAttachment <> vbNullString Then .Attachments.Add(New Net.Mail.Attachment(sAttachment)) End If .From = New MailAddress(sFromEmail, sFromName) .ReplyTo = New MailAddress(sReplyTo) .Subject = sSubject .IsBodyHtml = True .Body = sMessage End With For i = 0 To lstRecipients.Count - 1 mail.To.Add(lstRecipients(i)) Debug.Print(lstRecipients(i)) Try smtp.Send(mail) lSent += 1 bwrkMain.ReportProgress(CInt(100 * (i + 1) / iTotalRecipients)) SetStatus("Sent:" & lstRecipients(i)) Catch ex As Exception bwrkMain.ReportProgress(CInt(100 * (i + 1) / iTotalRecipients)) SetStatus("Not Sent:" & lstRecipients(i)) End Try mail.To.Clear() Next


Leave it up to the SMTP server to distribute the email to the recipients.

For i = 0 To lstRecipients.Count - 1 mail.To.Add(lstRecipients(i)) Next smtp.Send(mail)

Use the Bcc property if you don't want the recipient to see the other names.


You might want to switch to "pickup mode" where the mail client drops the message(s) in the local IIS SMTP dispatch location instead. That way you're sending mail asynchronously (sorta), although you'll have to install and configure the SMTP component.

Your code seems fine to me, the lag must be in the relay server you're using.


  • How to change directory permissions/chmod on FTP server using FtpWebRequest/WebRequest (C#)?
  • phpMyAdmin Access denied [closed]
  • How to write Delphi ActiveX control which can be used in MS Word/Excel/Powerpoint?
  • JFrame attached on the side of another JFrame
  • Rewriting Amazon S3 static urls [closed]
  • LocateRegistry.createRegistry
  • SSIS is executing successfully, but it doesn't seem to be running the script task portion
  • How do I use cURL & PHP to spoof the referrer?
  • python & Mysql: unsupported operand type(s) for -: 'int' and 'tuple'
  • Laravel Eloquent integration in Codeigniter
  • Soap Envelope Header in Delphi 7 not including utf-8 encoding. How can I modify it?
  • proxy request in node.js / express
  • How to fail Phing without triggering backtrace
  • Checking whether the server is on/off
  • x-axis labels in coreplot not displayed
  • SmtpClient sends email to junk
  • Bash extract user for a particular host from ssh config file
  • IllegalArgumentException: The servlets named [HelloWorlds] and [Hello] are both mapped to the url-pa
  • Excel 2007: Format of email address from Outlook 2007
  • Android NFC read Tags issue. Activity starts each time on data received
  • openssl handshake failed
  • How to resolve docker host names (/etc/hosts) in containers
  • Updating and removing unique join relationships in CakePHP
  • Negating Regex PO BOX
  • ASP.NET windows authentication should always ask for credentials
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • Get object from AWS S3 as a stream
  • Cross-Platform Protobuf Serialization
  • Validaiting emails with Net.Mail MailAddress
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Do I've to free mysql result after storing it?
  • Invalid access key error using credentials redeemed from an amazon open id token
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • need help with bizarre java.net.HttpURLConnection behavior
  • How does Linux kernel interrupt the application?
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs