send email with formatted table

Option Explicit

Sub SendEmail()

Dim olApp As Object, newEmail As Object

Set olApp = New outlook.Application
Set newEmail = olApp.CreateItem(olMailItem)


With newEmail:
    .To = Sheet1.Range("f18").Text
    .Subject = Sheet1.Range("g18").Text
    
    .Display
        
    Dim xInspect As Object, pageEditor As Object
    
    Set xInspect = newEmail.GetInspector
    Set pageEditor = xInspect.WordEditor
    
    Sheet1.Range("a1:h15").Copy
    
    pageEditor.Application.Selection.Start = Len(.Body)
    pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
    pageEditor.Application.Selection.Paste
    
    .Send
    
    Set pageEditor = Nothing
    Set xInspect = Nothing
End With

Set newEmail = Nothing
Set olApp = Nothing

End Sub
posted @ 2017-08-29 16:54  idlewith  阅读(412)  评论(0编辑  收藏  举报