save send email as file

G

Guest

Hi,
We like to save the emails we send as textfile on a file server. I want to
use the System. Web.Mail class for sending the email. The question is how can
i save the message as file. I have tried to use the msgMail.ToString() method
but this won't help, or i have to type cast te MailMessage as a string, but i
donýt know how to do this.

Thanks,
Marc
 
G

Guest

=?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?=
Hi,
We like to save the emails we send as textfile on a file server. I
want to use the System. Web.Mail class for sending the email. The
question is how can i save the message as file. I have tried to use
the msgMail.ToString() method but this won't help, or i have to type
cast te MailMessage as a string, but i donýt know how to do this.


NSoftware's SMTP component or FreeSMTP.net can save an e-mail to a file.
 
G

Guest

After you sent the Message you can use its various properties to compose the
content to save in a file that looks like the email you sent:

Private Sub WriteEmailToAFile( _
ByVal Message As System.Web.Mail.MailMessage, _
ByVal strFilePath As String)
Dim sw As System.IO.StreamWriter = _
New System.IO.StreamWriter(strFilePath)
sw.Write("<html><head></head><body>")
sw.Write("<p>Date: " & Now.ToLongDateString & _
" @ " & Now.ToLongTimeString & "</p>")
sw.Write("<P>To:" & Message.To & "</p>")
sw.Write("<p>From: " & Message.From & "</p>")
sw.Write("<p>Subject: " & Message.Subject & "</p>")
sw.Write("<div>Body: " & Message.Body & "</div>")
sw.Write("</body></html>")
sw.Close()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top