1

I am using the sample code below in sending emails. How can i save it first as an eml file before sending it as email in vb.net

Dim SmtpServer As New SmtpClient("smtp.exampledomain.com", 25) 
Dim mails As New MailMessage("user@exmple.com", "someuser", "TEST EMAIL", "Sample Message")    
SmtpServer.Credentials = New Net.NetworkCredential(user@exmple.com, "password")
SmtpServer.Send(mails)

Any suggestion is highly appreciated. Thank you.!

reiwin462
  • 71
  • 1
  • 1
  • 8

2 Answers2

1

To the person who have advised me on this thread to use this approach sorry if I did not fully Understand.. Appreciated your efforts!

This code solves my current issue with vb.net email.

SmtpClient.Credentials = New Net.NetworkCredential("login@sample", "user@123") SmtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory SmtpClient.PickupDirectoryLocation = Environ$("USERPROFILE") & "\Local Settings\Temp\FOLDER\" SmtpClient.Send(mails) SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network SmtpClient.Send(mails) SmtpClient.Dispose()

reiwin462
  • 71
  • 1
  • 1
  • 8
0

"*.EML" is a Microsoft Mail Format (Outlook, Outlook express) and some other clients can open/save it. You have to convert your email manually to such a format and store it on disk - .net does not provide any methods to convert you MailMessage to such a file. i don't think this is an easy task. I think you got something wrong.

Alternatively you can access outlook via MAPI - Than the Mapi-MailItem supports a Save-Method to store this mail on disk.

EDIT: Someone did this: look here: stackoverflow 1264672

Community
  • 1
  • 1
Cadburry
  • 1,844
  • 10
  • 21