save send email as file

Discussion in 'ASP .Net' started by =?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?=, Mar 24, 2006.

  1. 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
     
    =?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?=, Mar 24, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?=

    Spam Catcher Guest

    =?Utf-8?B?TWFyYyBIb2Vpam1hbnM=?=
    <> wrote in
    news::

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

    --
    Stan Kee ()

    Boycott StarForce!
    http://www.glop.org/starforce
     
    Spam Catcher, Mar 24, 2006
    #2
    1. Advertising

  3. 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

    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Marc Hoeijmans" wrote:

    > 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
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Mar 24, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter
    Replies:
    0
    Views:
    3,374
    Peter
    Jul 1, 2003
  2. Replies:
    2
    Views:
    410
    Tintin
    Jan 5, 2007
  3. Replies:
    13
    Views:
    492
    Randy Webb
    May 14, 2006
  4. pbd22
    Replies:
    1
    Views:
    155
  5. ashish makani
    Replies:
    5
    Views:
    610
    Mark Lawrence
    Sep 20, 2012
Loading...

Share This Page