You are reading a single comment by @aggi and its replies. Click here to read the full conversation.
  • Weird, works fine for me on Outlook/Excel 2013. Must be something in the setup somewhere.

    Just tested this and works fine

    Sub BGEmailLeeh()
     
     
       
        
       Dim OutApp As Outlook.Application
        Dim OutMail As Outlook.MailItem
        
        
        
        
            Set OutApp = CreateObject("Outlook.Application")
            Set OutMail = OutApp.CreateItem(olMailItem)
         
              On Error Resume Next
              ' Change the mail address and subject in the macro before you run it.
             With OutMail
            .To = "test@email.com"
            
            .Subject = " Test email "
            
            .Body = "Dear "
            
            .Attachments.Add "c:\Template.xls"
    
           '.Display    ' ".Display" allows you to display the email without sending
           .Send       ' ".Send" will send it automatically. Choose which option you want
            End With
        
        On Error GoTo 0
    
    Set OutMail = Nothing
    Set OutApp = Nothing
        
    End Sub
    

    You need to add the Microsoft Outlook 15.0 Object Library and the Microsoft Forms 2.0 Object Library to your references (numbers may vary)

  • That's good. I've not tried it since excel 2003, when you definitely couldn't do it without sendkeys. We certainly weren't running an international scale reporting solution using it. Ahem.

    Sendkeys in general is a pain due to being impossible to debug.

About

Avatar for aggi @aggi started