Results 1 to 3 of 3

Macro does the Display and Sent 1st email but then Error

Threaded View

  1. #1
    Registered User
    Join Date
    11-02-2014
    Location
    Marbella, Spain
    MS-Off Ver
    Excel Mac 2016
    Posts
    77

    Macro does the Display and Sent 1st email but then Error

    Hello all,

    Please, Im trying to send a bulk email and I would need help for an error that does not let me send more than 1 email. (I attached the file)

    My Macro has 3 parts.

    MACRO 1 - First I copy a all data base from one sheet to other:
    Sub Reponer_BaseDados()
    '
        Sheets("Base Dados ").Select
        Columns("B:D").Select
        Selection.Copy
        Sheets("Copia to Macro").Select
        Range("B1").Select
        ActiveSheet.Paste
    End Sub

    MACRO 2 - Macro for send email
    Sub PrepararMailInicial()
    
    Dim ThisFile As String
    
        col = Range("J1").Column
        For i = 2 To Range("D" & Rows.Count).End(xlUp).Row
            Set mail = CreateObject("outlook.application").CreateItem(0)
            mail.To = Range("D" & i)
            mail.CC = Range("E" & i)
            mail.BCC = Range("F" & i)
            mail.Subject = Range("G" & i)
            mail.body = Range("H" & i)
       ThisFile = "C:\BusCard.png"
            mail.Attachments.Add ThisFile, olByValue, 0
            mail.HTMLBody = Range("H8").Value & "<br>" & _
                            Range("H9").Value & "<br>" & _
                            Range("H10").Value & "<br>" & _
                            Range("H11").Value & "<br>" & _
                            Range("H12").Value & "<br>" & _
                            Range("H13").Value & "<br>" & _
                            Range("H14").Value & "<br>" & _
                            Range("H15").Value & "<br>" & _
                            Range("H16").Value & "<br>" & _
                            Range("H17").Value & "<br>" & _
                            Range("H18").Value & "<br>" & _
                            Range("H19").Value & "<br>" & _
                            Range("H20").Value & "<br>" & _
                            Range("H21").Value & "<br>" & _
                            Range("H2").Value & "<br>" & _
                            Range("H3").Value & "<br>" & _
                            Range("H4").Value & "<br>" & _
                            Range("H5").Value & "<br>" & _
                            Range("H6").Value & "<br>" & _
                            "<img src=""cid:BusCard.png""height=201 width=320>"
    
            For j = col To Cells(i, Columns.Count).End(xlToLeft).Column
                archivo = Cells(i, j)
                    If archivo <> "" Then mail.Attachments.Add archivo
            Next
            mail.Display 'display but not send
            'mail.Send 'send mail
    
            Next
        'MsgBox "Todos os emails enviados", vbInformation, "BR"
    End Sub
    PS: between the lines "Range("H2").Value & "<br>" & _" and "Range("H3").Value & "<br>" & _" should be a line that is format of the text but it denies the access to include it on the text.


    MACRO 3 - To try to avoid problems of outlook block, I divide the list in packs of 50 and cut/paste
    Sub Copiar_Mail_Info_A_Enviar()
    
        Sheets("Copia to Macro").Select
    
        k = 2
            Do Until IsEmpty(Cells(k, 2))
            Sheets("Copia to Macro").Select
            Range("B2:D6").Select
            Application.CutCopyMode = False
            Selection.Copy
            Sheets("Hoja1").Select
            Range("B3").Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False
            Sheets("Copia to Macro").Select
            Rows("2:6").Select
            Application.CutCopyMode = False
            Selection.Delete Shift:=xlUp
            Sheets("Hoja1").Select
            Call PrepararMailInicial
            k = k + 1
        Loop
    End Sub
    I did a test with only 15 emails and send in packs of 5. The emails appear but error when sent on this line on Macro 2:

            Set mail = CreateObject("outlook.application").CreateItem(0)
    Also please on this line of the Macro 2,
            mail.HTMLBody = Range("H8").Value & "<br>" & _
    I would like to add to this the name of the company according the lines. Something similar with:
           mail.HTMLBody = Range("H8").Value & "<br>" & Range("B" & i).value & _
    But also appear error. This mus be a silly error anyway.

    Thank you very much for your help.

    Cheers
    Attached Files Attached Files
    Last edited by coolx72; 06-18-2019 at 07:50 PM. Reason: Add info

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Save & Email Run-time error 2147024864
    By Dotreena in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2018, 03:24 PM
  2. Sometimes getting run time error 91 when running macro to email attachment
    By armlegx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2017, 06:37 PM
  3. Excel Macro to open outlook email returning error 429
    By laxminarayana in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2016, 03:21 AM
  4. Need VBA Macro to display custom Error Message
    By JChesney in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2015, 05:07 PM
  5. Run-time error 70 when button is clicked to run macro that opens email
    By blacklotus0014 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-02-2013, 09:54 AM
  6. [SOLVED] Send email upon error in macro
    By DarthWire in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2013, 02:44 PM
  7. Spacing error with Email Macro
    By dsrt16 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-20-2009, 03:40 AM

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