development:net:send_eml_from_disk

Send an e-mail stored on disk as .eml file in vb.net

If you have stored messages in .eml format on disk, and want to send them, the procedure is quite complicated. Luckily Peter Huber wrote some code to make this as simple as possible.

The following code uses a library based on the code written by Peter Huber, Singapore, 2006 http://www.codeproject.com/Articles/76607/Easily-Retrieve-Email-Information-from-EML-Files-R

So, we have messages saved on disk as .eml. Try to send them again using this code:

Dim FailedEmailFiles = Directory.EnumerateFiles("c:\temp\eml", "*.eml", SearchOption.TopDirectoryOnly)
For Each FailedEmailFile As String In FailedEmailFiles
Dim objMR As New CS.Mail.MimeReader
Dim mm As CS.Mail.RxMailMessage = objMR.GetEmail(FailedEmailFile.ToString)
Dim smtp As New Mail.SmtpClient(SmtpIP)
Try
smtp.Send(mm)
File.Delete(FailedEmailFile.ToString)
Catch exc As Exception

End Try
smtp.Dispose()
smtp = Nothing
mm.Dispose()
mm = Nothing
Next
FailedEmailFiles = Nothing
  • development/net/send_eml_from_disk.txt
  • Last modified: 2019/10/31 09:04
  • by 127.0.0.1