1
     Dim msg As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
    msg.BodyEncoding = Encoding.UTF8
    msg.SubjectEncoding = Encoding.UTF8

    Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(PrintablePage.StripHTML(body).Trim, System.Text.Encoding.UTF8, "text/plain")
    msg.AlternateViews.Add(plainView)
    Dim userState As Object = msg

    Response.Write(userState)

I extract the eml file and get the body message to be able to insert the database as varchar datatype. The problem here is that how to convert the eml file to string in vb.net. I am using .net 3.5 sp1 and Database is MSSQL 2008. Thanks in advance.

z0mbie
  • 57
  • 1
  • 1
  • 10
  • Your question is unclear - are you trying to load the EML file from disk? It's not clear how your code relates to your problem, or what your input is. – Jon Skeet Mar 12 '12 at 07:03
  • yes I am trying to load EML from the remote server and extract the message from EML file. I got the message from eml file and try to covert it into string using the above code. The coveted message are still unreadable to insert the database. – z0mbie Mar 12 '12 at 07:12
  • Which remote server? Sorry, your question is still very unclear. Please read http://tinyurl.com/so-hints. Do you really have to have it as a string anyway? Why not store it as a blob? – Jon Skeet Mar 12 '12 at 07:13
  • I don't know how to use blob.Is there any other way to covert the eml data? – z0mbie Mar 12 '12 at 07:18
  • Well I don't know anything about the EML file format. If it's just opaque binary data, you could use base64 to encode it... but why bother? That's what blobs are for - if you don't know how to use them, then learn rather than working around it. Of course if the EML file *is* naturally text in some encoding, then just read it in that encoding. – Jon Skeet Mar 12 '12 at 07:20
  • An `eml` file is nothing than a plain binary, so you should store it as binary in dbms. If you really neeed to convert this to a string, have a look at this answer: http://stackoverflow.com/a/473574/284240 – Tim Schmelter Mar 12 '12 at 08:29

0 Answers0