• Notice regarding image hosts and attachments. See here.

Basic VBA Help

Soldato
Joined
26 Mar 2007
Posts
9,230
Location
Nottinghamshire
Total VB noob here so please excuse my lack of knowledge!

Currently setting up a spreadsheet for my Ops team to send out via at the end of each shift. I'm trying to automate where possible and am partially there but need a little help.

The below code is successfully attaching the full workbook and creating a new email via a macro button but I'd also like to get the contents of a worksheet named 'Summary' included in the body of the email when they press that same button to email.

Whats the best/ easiest way of doing this? Any help appreciated

Code:
  Sub Mail_workbook_Outlook_1()
    
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .to = "[email protected]"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = "Hi there"
        .Attachments.Add ActiveWorkbook.FullName
        .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
 
Back
Top Bottom