0

I contact several colleagues across different departments and due to compliance the default email signature is to be used on all emails.

I managed to produce a blanket email, using Excel VBA, that has the same body across all emails with changes based on the staff's location and criteria.

My signature is not populated.

Sub send_mass_email()
    Dim i As Integer
    Dim Greeting, email, body, subject, business, Website As String
    Dim OutApp As Object
    Dim OutMail As Object
    
    body = ActiveSheet.TextBoxes("TextBox 1").Text
    
    i = 2
    
    Do While Cells(i, 1).Value <> ""
        
        Greeting = Cells(i, 2).Value
        email = Cells(i, 3).Value
        body = ActiveSheet.TextBoxes("TextBox 1").Text
        subject = Cells(i, 4).Value
        business = Cells(i, 1).Value
        Website = Cells(i, 5).Value
        
        ' replace place holders
        body = Replace(body, "B2", Greeting)
        body = Replace(body, "A2", business)
        body = Replace(body, "E2", Website)
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        With OutMail
            .to = email
            .subject = subject
            .body = body & Signature
            '.Attachments.Add ("") 'You can add files here
            .display
            '.Send
        End With
        
        'reset body text
        body = ActiveSheet.TextBoxes("TextBox 1").Text
        
        i = i + 1
    Loop
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    MsgBox "Email(s) Sent!"
    
End Sub
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

1 Answers1

0

Call the Display method before making any body-related modifications to generate/add the default signature in the message body:

With OutMail
            .display

            .to = email
            .subject = subject
            '.body = body & Signature
            '.Attachments.Add ("") 'You can add files here
            
            '.Send
End With
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45