Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("C:\\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:\\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
msg = o.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
msg.Subject = "SO & ProOrd & PurchasingOrd Overview"
msg.Attachments.Add("C:\\Data\\Data.xlsx")
Dim body As String = "<html><body>内容</body></html>"
Dim bmp As new Bitmap("C:\\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("sli@aexrb.com")
msg.Send()
app.quit
msgbox("Done")