Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("C:\Users\wj1087\Desktop\改善项目\Project\Data\Data.xlsx")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(2)'指定工作表
Dim range = ws.range("B1:I22")
range.CopyPicture(Appearance:=1, Format:=2)
ClipBoard.GetImage.save("C:\Users\wj1087\Desktop\改善项目\Project\Data\Data1.jpg")
Dim o As New Microsoft.Office.Interop.Outlook.Application
Dim msg As Microsoft.Office.Interop.Outlook.MailItem
Dim m As New MailSender
Dim ln As String = vbcrlf & vbcrlf
Dim dr As DataRow
msg = o.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
msg.Subject = "Sales Order & Production order Overview"
msg.Attachments.Add("C:\Users\wj1087\Desktop\改善项目\Project\Data\Data.xlsx")
Dim body As String = "<html><body>内容</body></html>"
Dim bmp As new Bitmap("C:\Users\wj1087\Desktop\改善项目\Project\Data\Data1.jpg") '图片路径
Dim ms As new System.Io.MemoryStream()
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arr(ms.Length) As Byte
ms.Position = 0
ms.Read(arr, 0, ms.Length)
ms.Close()
Dim strbase64 As String = Convert.ToBase64String(arr)
bmp.dispose
Dim content As String ="<img style = ""height:20px"" src=""data:image/jpeg;base64," & strbase64 & """ > "
msg.HTMLBody = body.Replace("内容", " "& content)
msg.Recipients.Add("summer@bxiexe.com")
msg.Send()
msgbox("Done")