reiwin462
reiwin462

Reputation: 71

How Do I save my composed email content as (.eml) before sending in vb.net

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("[email protected]", "someuser", "TEST EMAIL", "Sample Message")    
SmtpServer.Credentials = New Net.NetworkCredential([email protected], "password")
SmtpServer.Send(mails)

Any suggestion is highly appreciated. Thank you.!

Upvotes: 1

Views: 1441

Answers (2)

reiwin462
reiwin462

Reputation: 71

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()

Upvotes: 1

Cadburry
Cadburry

Reputation: 1864

"*.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

Upvotes: 0

Related Questions