Convert image stored on remote folder to base64 in web app - html

In my web app i need to convert images on catalog to string
Catalogue are created in a listview with .NET Framework 4 using webform
Protected Sub ProductsLv_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ProductsLv.ItemDataBound
If e.Item.ItemType = ListViewItemType.DataItem Then
Dim dataRow = DirectCast(e.Item.DataItem, DataRowView)
Dim path = Replace("~/Products/Immagine.ashx?FileName=" & dataRow("ImageName"), "\\machine\Foto\", "")
path = "http://" & Me.Request.Url.Host & ResolveUrl(path)
Dim sBase64 As String = "data:image/jpeg;base64,"
Using w As New System.Net.WebClient()
Dim buffer As Byte() = w.DownloadData(path)
sBase64 &= Convert.ToBase64String(buffer)
End Using
DirectCast(e.Item.FindControl("myIMG"), System.Web.UI.WebControls.Image).ImageUrl = sBase64
End If
End Sub
Code above seems works well because i found string on image source of html produced by server response
but images are not visible
What mistake i making?
The value of sBase64 is
data:image/jpeg;base64,DQo8IURPQ1RZUEUgaHRtbCBQVUJMSUMgIi0vL1czQy8vRFREIFhIVE1MIDEuMCBUcmFuc2l0aW9uYWwvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIveGh0bWwxL0RURC94aHRtbDEtdHJhbnNpdGlvbmFsLmR0ZCI+DQoNCjxodG1sIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hodG1sIj4NCjxoZWFkPjx0aXRsZT4NCglMb2dpbg0KPC90aXRsZT4NCiAgICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KICAgICAgIC5mYWlsdXJlTm90aWZpY2F0aW9uDQp7DQogICAgZm9udC1zaXplOiAxLjJlbTsNCiAgICBjb2xvcjogI0ZGMDA2NjsNCiAgICBmb250LXdlaWdodDpib2xkOw0KfQ0KICAgIDwvc3R5bGU+DQoNCiAgICA8bGluayBocmVmPSIuLi9Db250ZW50L2Jvb3RzdHJhcC5jc3MiIHJlbD0ic3R5bGVzaGVldCIgLz48bGluayBocmVmPSIuLi9Db250ZW50L2Jvb3RzdHJhcC5taW4uY3NzIiByZWw9InN0eWxlc2hlZXQiIC8+PC9oZWFkPg0KPGJvZHk+DQogICAgPGZvcm0gbWV0aG9kPSJwb3N0IiBhY3Rpb249Ii4vTG9naW4uYXNweD9SZXR1cm5Vcmw9JTJmYmVwc2l0ZSUyZkFydGljb2xpJTJmSW1tYWdpbmUuYXNoeCUzZkZpbGVOYW1lJTNkVFNTVDE5NzFTdGFtcGEuanBnJmFtcDtGaWxlTmFtZT1UU1NUMTk3MVN0YW1wYS5qcGciIGlkPSJmb3JtMSIgY2xhc3M9ImZvcm0tc2lnbmluIj4NCjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9Il9fVklFV1NUQVRFIiBpZD0iX19WSUVXU1RBVEUiIHZhbHVlPSIvd0VQRHdVS0xUVXpNVGcyTVRNM05tUmtQV3czNk1WWnBBZnNzV3QyUkRBK0tzQ0NjUVJsNjJxTHhVeEVpWHRhbUM4PSIgLz4NCg0KDQo8c2NyaXB0IHNyYz0iL2JlcHNpdGUvU2NyaXB0UmVzb3VyY2UuYXhkP2Q9bXYxazZ3emZNRi1CYWt5ZG13LWd0eU9FN3VWdUJRS2lIcGNac1VpLUpEMk1nWXdUeENnZE5mY0hYaDVsT1ZIeU5ZVklEUnplODJvNXpNQUhLdUdkc0pXblFTeFVWMDg1aTdGTHA0Yk13TUlFamQwaC1mdWduRTVhVmtxa2JUeGVaTlBsVF9pdnh1ZWkzbUdhOWE1aWd3MiZhbXA7dD1mZmZmZmZmZmYyYjFlZjM4IiB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPjwvc2NyaXB0Pg0KPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPg0KLy88IVtDREFUQVsNCmlmICh0eXBlb2YoU3lzKSA9PT0gJ3VuZGVmaW5lZCcpIHRocm93IG5ldyBFcnJvcignSW1wb3NzaWJpbGUgY2FyaWNhcmUgaWwgZnJhbWV3b3JrIGxhdG8gY2xpZW50IGRpIEFTUC5ORVQgQWpheC4nKTsNCi8vXV0+DQo8L3NjcmlwdD4NCg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iX19WSUVXU1RBVEVHRU5FUkFUT1IiIGlkPSJfX1ZJRVdTVEFURUdFTkVSQVRPUiIgdmFsdWU9IkY2MUEzOEQzIiAvPg0KPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iX19FVkVOVFZBTElEQVRJT04iIGlkPSJfX0VWRU5UVkFMSURBVElPTiIgdmFsdWU9Ii93RWRBQVNaa2s5NkFIMURzbThJYmpWTzNDRkRIZk9mcjkxK1lJMlhWaFAxYy9wR1I5NkZZU2ZvNUpVTFlWdmZRNjEvVXc3c05VWWxPZU8va2F3Y245ZlgwQnBXOFR5NjJvM3hqK3pSMEhHQ1kxVG1NZnNDU1NVWGJONThCaDY3MXROaUF4Zz0iIC8+DQogICAgICA8ZGl2IGNsYXNzPSJjb250YWluZXIiIHN0eWxlPSJ3aWR0aDogNDAwcHgiPg0KICAgICA8aDIgc3R5bGU9InRleHQtYWxpZ246IGNlbnRlciIgPg0KICAgICAgICBBY2NlZGkNCiAgICA8L2gyPg0KICAgIDxwPg0KICAgICAgIA0KICAgICAgDQoNCiAgICAgICAgICANCiAgIA0KICAgDQogICAgICAgICAgICANCiAgICAgICANCiAgICANCiAgICAgICAgICAgIDxzcGFuIGNsYXNzPSJmYWlsdXJlTm90aWZpY2F0aW9uIj4NCiAgICAgICAgICAgICAgICANCiAgICAgICAgICAgIDwvc3Bhbj4NCiAgICAgICAgICAgIA0KICAgICAgICAgICAgPGRpdiBjbGFzcz0iYWNjb3VudEluZm8iPg0KICAgICAgICAgICAgICAgIDxmaWVsZHNldCBjbGFzcz0ibG9naW4iPg0KICAgICAgICAgICAgICAgICAgICA8bGVnZW5kPkFjY291bnQ8L2xlZ2VuZD4NCiAgICAgICAgICAgICAgICAgICAgPHA+DQogICAgICAgICAgICAgICAgICAgICAgICANCiAgICAgICAgICAgICAgICAgICAgICAgIDxpbnB1dCBuYW1lPSJMb2dpblVzZXIkVXNlck5hbWUiIHR5cGU9InRleHQiIGlkPSJMb2dpblVzZXJfVXNlck5hbWUiIGNsYXNzPSJmb3JtLWNvbnRyb2wiIHBsYWNlaG9sZGVyPSJ1dGVudGUiIC8+DQogICAgICAgICAgICAgICAgICAgICAgICAmbmJzcDsNCiAgICAgICAgICAgICAgICAgICAgPC9wPg0KICAgICAgICAgICAgICAgICAgICA8cD4NCiAgICAgICAgICAgICAgICAgICAgICAgIA0KICAgICAgICAgICAgICAgICAgICAgICAgPGlucHV0IG5hbWU9IkxvZ2luVXNlciRQYXNzd29yZCIgdHlwZT0icGFzc3dvcmQiIGlkPSJMb2dpblVzZXJfUGFzc3dvcmQiIGNsYXNzPSJmb3JtLWNvbnRyb2wiIHBsYWNlaG9sZGVyPSJwYXNzd29yZCIgLz4NCiAgICAgICAgICAgICAgICAgICAgICAgICZuYnNwOw0KICAgICAgICAgICAgICAgICAgICA8L3A+DQogICAgICAgICAgICAgICAgICAgDQogICAgICAgICAgICAgICAgPC9maWVsZHNldD4NCiAgICAgICAgICAgICAgICA8cCBjbGFzcz0ic3VibWl0QnV0dG9uIj4NCiAgICAgICAgICAgICAgICAgICAgPGlucHV0IHR5cGU9InN1Ym1pdCIgbmFtZT0iTG9naW5Vc2VyJExvZ2luQnV0dG9uIiB2YWx1ZT0iQWNjZWRpIiBvbmNsaWNrPSJqYXZhc2NyaXB0OldlYkZvcm1fRG9Qb3N0QmFja1dpdGhPcHRpb25zKG5ldyBXZWJGb3JtX1Bvc3RCYWNrT3B0aW9ucygmcXVvdDtMb2dpblVzZXIkTG9naW5CdXR0b24mcXVvdDssICZxdW90OyZxdW90OywgdHJ1ZSwgJnF1b3Q7TG9naW5Vc2VyVmFsaWRhdGlvbkdyb3VwJnF1b3Q7LCAmcXVvdDsmcXVvdDssIGZhbHNlLCBmYWxzZSkpIiBpZD0iTG9naW5Vc2VyX0xvZ2luQnV0dG9uIiBjbGFzcz0iYnRuIGJ0bi1sZyBidG4tcHJpbWFyeSBidG4tYmxvY2siIC8+DQogICAgICAgICAgICAgICAgPC9wPg0KICAgICAgICAgICAgPC9kaXY+DQogICAgICAgIA0KICAgICANCiAgICA8L2Rpdj4NCiAgICA8L2Zvcm0+DQo8L2JvZHk+DQo8L2h0bWw+DQo=

ImageUrl needs a relative or absolute path. So try setting “src” attribute instead, as follows.
DirectCast(e.Item.FindControl("myIMG"), System.Web.UI.WebControls.Image).Attributes("src") = sBase64

Related

How to extract an Image from HTML file using VB.net

I have few HTML files which has images stored in binary format like below
<img src="data:image/png;base64,iVBORw0KGgoAAAANS............>
Only one image per HTML file
I need to extract image from each file and save them to png or jpg using a .net application
Any help is appreciated
Thanks
Jiju
Try this:
Imports System.Drawing
Module Module1
Sub Main()
Dim ImageText = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAFEUExURf////+Kh/+Gg//j4//BwP97eP9jX/+Bfv+5uP/29v+HhP+Mif+mpP/b2/8tJ/8IAP+/vv9ybv8cFv9zb/+1tP9xbf/7+/8uKP/q6v/6+v9KRf9aVv/h4f/9/f/Q0P9AO/9nY/9wbP/09P/Av/85NP+Niv/w8P+tq/9fW//5+f8pI//W1v/OzP82Mf8xK/82MP+Jhv99ev8aFP8SC/8zLf8TDP83Mv81MP/s7P81L/96d/84M/9CPf/19f86Nf8sJv9va/9BPP87Nv8yLP9XU/8RCv8kHv89OP9dWf+cmv8+Of8bFf8hG/+urP90cf94df9TTv+opv9STf+2tf+Aff9EP//Cwf/Y2P9MR/9GQf9taf8gGv+Tkf+Vk/9UUP8WD//FxP9JRP+kov8mIP8XEf9hXf/V1f+0s//39//e3v/S0v/i4pkRhsgAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE5SURBVEhL7ZJXU8JAFIWvqKgoHlE0RBGwoChWVKyI2Hvvvdf//+7evcmMZCIzvjr5HrL3nN1vNpkJeXh4ePyFMp9NuUoVlX5/VbXeqAkEArV1QT0XUw+bBqIQ0KimJt4IS9usTxXRojAQMU2TqBVtUWqPxZFQG2F0mJ1d3UjKOQcGenjpRUrHvn6kWQmpeQCDunMyJMowvxszglFbocyYrpyMizKR0YkoxteJEkVWOgeTWpnCtESKIG4rM3yhC7NaSWNOIuUwz0p+IZVFweocLGolhyWJFMQyKyura+sbVuVkU75la1snoh3ssrJnRTcKouzjQEc6xBErx5JcORHlFMYZr0mcq2cYPg6/cCEKXeIqcX1zi7t7FUorD5ZCj0/qr3p+eeX5raRC79ZK9PH5ZU0/Sg+PfwXRN1h4IRCn6GVqAAAAAElFTkSuQmCC"
'We don't need 'data:image/png;base64,'
ImageText = ImageText.Split(",")(1)
Dim bitmapData As Byte() = Convert.FromBase64String(FixBase64ForImage(ImageText))
Dim streamBitmap As System.IO.MemoryStream = New System.IO.MemoryStream(bitmapData)
Dim bitImage As Bitmap = New Bitmap(CType(Image.FromStream(streamBitmap), Bitmap))
bitImage.Save("c:\temp\test1.png", Imaging.ImageFormat.Png)
End Sub
Public Function FixBase64ForImage(ByVal Image As String) As String
Dim sbText As System.Text.StringBuilder = New System.Text.StringBuilder(Image, Image.Length)
sbText.Replace(vbCrLf, String.Empty)
sbText.Replace(" ", String.Empty)
Return sbText.ToString()
End Function
End Module

Get website's inner text without webbrowser

I want to get website's inner text through code.
I can already get it's inner html with code below, but i can't find any code that's getting URL's inner text without webbrowser.
This code is getting text from website in webbrowser, but i need same thing, just without webbrowser.
Dim sourceString As String = WebBrowser1.Document.Body.InnerText
With HtmlAgilityPack...
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
Dim doc As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument
With New Net.WebClient
doc.LoadHtml(.DownloadString("https://example.com"))
.Dispose()
End With
Debug.Print(doc.DocumentNode.Name)
PrintChildNodes(doc.DocumentNode)
Debug.Print(doc.DocumentNode.Element("html").Element("body").InnerText)
End Sub
Sub PrintChildNodes(Node As HtmlAgilityPack.HtmlNode, Optional Indent As Integer = 1)
For Each Child As HtmlAgilityPack.HtmlNode In Node.ChildNodes
Debug.Print("{0}{1}", String.Empty.PadLeft(Indent, vbTab), Child.Name)
PrintChildNodes(Child, Indent + 1)
Next
End Sub
**Taken from **
Wolfwyrd
In this question HTTP GET in VB.NET
Try
Dim fr As System.Net.HttpWebRequest
Dim targetURI As New Uri("http://whatever.you.want.to.get/file.html")
fr = DirectCast(HttpWebRequest.Create(targetURI), System.Net.HttpWebRequest)
If (fr.GetResponse().ContentLength > 0) Then
Dim str As New System.IO.StreamReader(fr.GetResponse().GetResponseStream())
Response.Write(str.ReadToEnd())
str.Close();
End If
Catch ex As System.Net.WebException
'Error in accessing the resource, handle it
End Try
You will get Html as well as http headers. Don't think this will work by itself with https.

VB .NET server generating Excel file on the fly

I have a VB .NET web application running on a server with multiple requests and performance requirements.
I have a function that retrieves some data from a DB and has to generate an excel report to show to the system users.
I somehow did it, but my solution has not the performance I'd like it to have: basically what my code does is:
The server accepts the request of report generating
The server fills an excel file
The server saves locally the xls file
The server attaches the file to the html response and the user downloads it
The server deletes the file (when? I need to handle borderline cases too)
The code snippet is like:
Public Sub ExportaDataTableToExcel(ByVal dt As System.Data.DataTable, ByVal Page As System.Web.UI.Page, ByVal ReportName As String)
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim colIndex As Integer
Dim rowIndex As Integer
oExcel = New Excel.Application
oBook = oExcel.Workbooks.Add(Type.Missing)
oSheet = oBook.Worksheets(1)
'Export the Columns to excel file
For Each dc In dt.Columns
colIndex = colIndex + 1
oSheet.Cells(1, colIndex) = dc.ColumnName
Next
oBook.SaveAs("C:\file.xls")
oSheet = Nothing
oBook.Close()
Page.Response.AddHeader("content-disposition", "attachment;filename=" & ReportName & ".xls")
Page.Response.Charset = String.Empty
Page.Response.ContentType = "vnd.application/ms-excel"
Page.Response.TransmitFile("C:\file.xls")
Page.Response.Flush()
Page.Response.End()
oExcel.Quit()
End Sub
As you can see the server generates the xls file locally in C:\file.xls, then trasmittes the file in the response page.
What I'd like to do, and I really don't know if it's possible as I did not found any example on this, is generating the xls file on the fly without saving it locally (maybe returning as a Stream of bytes or something like this) and then assembling this as xls file in the response page, without saving the file locally.
I tried using both Page and System.IO.StringWriter with no luck, maybe I'm doing something wrong.
The following code acts abnormally, asking me to save modifies on the file (on the server side), and downloading an xls file that has parts of the html of the page, generating errors about missing css files and displaying part of the page. So, with this approach I'm almost at zero. Here it is the code:
Public Sub ExportaDataTableToExcel(ByVal dt As System.Data.DataTable, ByVal Page As System.Web.UI.Page, ByVal ReportName As String)
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim colIndex As Integer
Dim rowIndex As Integer
oExcel = New Excel.Application
oBook = oExcel.Workbooks.Add(Type.Missing)
oSheet = oBook.Worksheets(1)
'Export the Columns to excel file
For Each dc In dt.Columns
colIndex = colIndex + 1
oSheet.Cells(1, colIndex) = dc.ColumnName
Next
oSheet = Nothing
oBook.Close()
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
Dim htmlWrite As System.Web.UI.Html32TextWriter = New System.Web.UI.Html32TextWriter(stringWrite)
Page.Response.Clear()
Page.Response.AddHeader("content-disposition", "attachment;filename=" & ReportName & ".xls")
Page.Response.Charset = String.Empty
Page.Response.ContentType = "vnd.application/ms-excel"
Page.Response.WriteFile(stringWrite.ToString)
Page.Response.Flush()
Page.Response.End()
oExcel.Quit()
End Sub
I know I can help with at least one of those problems you are having, Lateralus. Ive taken a snippet from our live server here to show you.
Edit: This one transmits a CSV file and we had the problem initially with the HTML showing up in the file. We opted to not use excel in this particular instance but, the problems are likely one in the same.
I believe that you need to add an additional header to your page response in order to remove the HTML that you are getting in the file.
Here is an example. As a warning, I'm not entirely sure how secure this method is. We use this within our network so it didn't need to be as locked down.
Dim LiveFileStream As FileStream = New FileStream("C:\inetpub\wwwroot\" &_
"Website\CSVFile.csv", FileMode.Open, FileAccess.Read)
Dim fileBuffer(CInt(LiveFileStream.Length)) As Byte
LiveFileStream.Read(fileBuffer, 0, CInt(LiveFileStream.Length))
LiveFileStream.Close()
Response.Clear()
Response.Charset = "utf-8"
Response.ContentType = "text/plain"
'I believe if you are to add the following header
'it will fix the problem with HTML showing in document
Response.AddHeader("Content-Length", fileBuffer.Length.ToString)
Response.AddHeader("Content-Disposition", "attachment; filename=CSVFile.csv")
Response.BinaryWrite(fileBuffer)
Response.End()

Creating 2D (Data Matrix or QR Codes) in MS Access Reports/Forms

We are in the process of implementing code to read/create 2D bar codes that are starting to show up on our supplier's parts.
We have a need to create the 2D bar codes in MS Access reports and forms. Has anyone had success with the font (IDAutomation) or Active X (dlSoft) solutions out there.
For C#, the open source library "http://barcoderender.codeplex.com/" was suggested. Any thoughts on how successful this was or if anyone has other open-source and/or pay for options.
Thanks,
Anton
Depending on the volume of codes you need to generate, you could use the Google Charts API to generate QR Codes.
Simply add a "Microsoft Web Browser" ActiveX component and the following code to your Form:
Dim Size As Integer
Dim Text As String
Dim URL As String
Size = 200
Text = "This is my test"
' Better to actually use a URL encoding function like those described here:
' http://stackoverflow.com/questions/218181/how-can-i-url-encode-a-string-in-excel-vba
Text = Replace(Text, " ", "%20")
URL = "http://chart.apis.google.com/chart?chs=" & Size & "x" & Size & "&cht=qr&chld=H|0&chl=" & Text
WebBrowser.Navigate (URL)
You can of course change the Size and the Text depending on your need. The Text can also be a value directly from your Form, therefore your data.
I would advise you to check Googles Terms and Services before using it.
I completely escaped the web browser control and the Google API since that functionality is now deprecated from what I can tell. I went with a different free API but the Google API or any other API could be used instead.
In my example I am creating an .png image in the same directory as the application. I have a text box on my form named txtToCode in which I type in any text I want to code. I also have an image control so that the image can be viewed from the form, but you can modify it how you wish:
Private Sub btnCode2_Click()
Call GetQRCode(Me.txtToCode, 150, 150)
End Sub
Sub GetQRCode(Content As String, Width As Integer, Height As Integer)
Dim ByteData() As Byte
Dim XmlHttp As Object
Dim HttpReq As String
Dim ReturnContent As String
Dim EncContent As String
Dim QRImage As String
EncContent = EncodeURL(Content)
HttpReq = "https://api.qrserver.com/v1/create-qr-code/?data=" & EncContent & "&size=" & Width & "x" & Height & ""
Set XmlHttp = CreateObject("MSXML2.XmlHttp")
XmlHttp.Open "GET", HttpReq, False
XmlHttp.Send
ByteData = XmlHttp.responseBody
Set XmlHttp = Nothing
ReturnContent = StrConv(ByteData, vbUnicode)
Call ExportImage(ReturnContent)
End Sub
Private Sub ExportImage(image As String)
Dim FilePath As String
On Error GoTo NoSave
' Build Export Path
FilePath = Application.CurrentProject.Path & "\qr.png"
Open FilePath For Binary As #1
Put #1, 1, image
Close #1
Me.Image3.Picture = FilePath
' Save File Path
Exit Sub
NoSave:
MsgBox "Could not save the QR Code Image! Reason: " & Err.Description, vbCritical, "File Save Error"
End Sub
Private Function EncodeURL(str As String)
Dim ScriptEngine As Object
Dim encoded As String
Dim Temp As String
Temp = Replace(str, " ", "%20")
Temp = Replace(Temp, "#", "%23")
EncodeURL = Temp
End Function

Trying to use a HTML file as my email body using iMsg in VB.NET

I've wrote a script to create a HTML file based on a SQL Query.... It has become necessary to have that HTML be emailed. Most of our execs use blackberry's and I want to send the HTML file as the body. I have found a round about way to get this done, by adding a WebBrowser, and having the web browser then load the file, and then using the below code to send. The problem i'm facing is if I automate the code fully, it will only email part of the HTML document, now if I add a button, and make it do the email function, it sends correctly. I have added a wait function in several different location, thinking it may be an issue with the HTML not being fully created before emailing. I have to get this 100% automated. Is there a way I can use the .HTMLBody to link to the actual HTML file stored on the C:(actual path is C:\Turnover.html). Thanks all for any help.
Public Sub Email()
Dim strdate
Dim iCfg As Object
Dim iMsg As Object
strdate = Date.Today.TimeOfDay
iCfg = CreateObject("CDO.Configuration")
iMsg = CreateObject("CDO.Message")
With iCfg.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xxxxx.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = """Turnover Report"" <TurnoverReports#xxxxx.com>"
.Update()
End With
With iMsg
.Configuration = iCfg
.Subject = "Turnover Report"
.To = "xxxxx#xxxxx.com"
'.Cc = ""
.HTMLBody = WebBrowserReportView.DocumentText
.Send()
End With
iMsg = Nothing
iCfg = Nothing
End Sub
used the below function to read in a local html file. then set
TextBox2.Text = getHTML("C:\Turnover2.html")
and also
.HTMLBody = TextBox2.Text
Private Function getHTML(ByVal address As String) As String
Dim rt As String = ""
Dim wRequest As WebRequest
Dim wResponse As WebResponse
Dim SR As StreamReader
wrequest = WebRequest.Create(address)
wResponse = wrequest.GetResponse
SR = New StreamReader(wResponse.GetResponseStream)
rt = SR.ReadToEnd
SR.Close()
Return rt
End Function