Results 1 to 14 of 14

Macro to delete first row and send an email with attachment

Threaded View

  1. #1
    Registered User
    Join Date
    04-22-2016
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    23

    Macro to delete first row and send an email with attachment

    Good day,

    At the moment i'm writing a macro to send an email with an attachment.

    What i would like is for the macro to delete the first row of the file and then shift the row up and then send the email , this is what i have so far :

    Private Sub CommandButton1_Click()
    
    
        Dim xOutApp As Object
        Dim xOutMail As Object
        Dim xMailBody As String
        Dim objOutlookRecip As String
        On Error Resume Next
        Set xOutApp = CreateObject("Outlook.Application")
        Set xOutMail = xOutApp.CreateItem(0)
          xMailBody = "Body content" & vbNewLine & vbNewLine & _
                  "This is line 1" & vbNewLine & _
                  "This is line 2"
                  
                      On Error Resume Next
      
    
    With xOutMail
       .To = "testemaill"
            .CC = ""
            .BCC = ""
            .Subject = "Test email send by button clicking"
            .Body = xMailBody
            .Display   'or use .Send
    'Add attachments to the message [some code]
       .Attachments.Add "C:\Users\user\Desktop\Test\testfile.xlsx"
    
       
    End With
    Set objOutlook = Nothing
    
    End Sub
    The above successfully attaches the file to the email.

    i know the line to delete the first row is
    Rows(1).EntireRow.Delete
    , but i'm not sure how to refer it to that specific file and have it run before attaching it to the email.

    There's about 20 files that i want to do this with and run it every first day of the month , are there any macros that would make this task easier?

    Any help would be appreciated.

    Kind regards
    Rynhardt
    Last edited by Aredeekay; 07-03-2018 at 10:00 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Send Email With PDF Attachment Macro to Multiple Recipients
    By Hoover5896 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2018, 10:34 PM
  2. [SOLVED] macro to convert email message to PDF and send as an attachment
    By melody10 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 06-20-2016, 02:18 AM
  3. Macro send worksheet as email attachment?
    By welshman010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2014, 09:36 PM
  4. Macro to send email with attachment for each unique email Ids
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-06-2014, 07:12 AM
  5. VBA Code: MACRO to send lotus notes email with excel attachment
    By FLani in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2013, 10:23 AM
  6. Macro to Send whole Sheet via Email in text format not as attachment
    By mobi4u in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2012, 04:37 PM
  7. Macro to send email with multiple attachment
    By excelcheck123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 05:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1