ADD EMAIL SIGNATURE TO CODE GENERATED EMAIL

JuicyMusic

Board Regular
Joined
Jun 13, 2020
Messages
210
Office Version
  1. 365
Platform
  1. Windows
Hi, How can I adjust this code to insert a saved email signature to the generated emails please? The saved signature will be MyComplianceSig
The body of the emails comes from typing something in a big text box. This code works perfectly but I can't find how to have my saved email signature be included in every generated email.

I will keep looking around to see if i can insert the section myself in the mean-time. I'm sure this must be a very generic section to add. Any response is appreciated, even though:)

I will upload a snapshot of my email distribution list sheet. Sorry, my company won't allow me to install XL2BB. Thank you so much!!

VBA Code:
Option Explicit

Sub EMAIL_Send_to_DistributionList()


    Dim OutlookApp As Object
    Dim MItem As Object
    Dim cell As Range
    Dim email_ As String
    Dim cc_ As String, bcc_ As String
    'Coco deactivated the 3rd and 4th "As String" of the line of code above.  Not needed because 2 TextBoxes were used instead.  See last section of this code.
    'subject_ As String, body_ As String
 
  'CG added this section of code to create a error message box
If WorksheetFunction.CountA(Range("A2:A350")) = 0 Then
    MsgBox "Please enter a minimum of one email address in Column A.", vbCritical, "Missing Email Address"
        Exit Sub
    End If
 
 'CG added this section of code to create a Yes/No Message Box
 Dim answer As Variant
    answer = MsgBox("Are you ready to generate your email?", vbYesNo + vbQuestion, "Email Disribution")
    If answer = vbNo Then
        Exit Sub
    End If
    

     'Create Outlook object
    Set OutlookApp = CreateObject("Outlook.Application")

     'Loop through the rows
    For Each cell In Range("A2:A350").Cells.SpecialCells(xlCellTypeConstants)

        email_ = cell.Value
        cc_ = cell.Offset(0, 1).Value
        bcc_ = cell.Offset(0, 2)
        'Coco deactivated the next two lines of code and used TexBoxes instead
       ' subject_ = cell.Offset(0, 3)
       ' body_ = cell.Offset(0, 4)

        'Create Mail Item and send it
        Set MItem = OutlookApp.CreateItem(0)
        With MItem
            .To = email_
            .CC = cc_
            .BCC = bcc_
            'CG changed the following line of code to recognize the 2nd TextBox
            .Subject = ActiveSheet.TextBoxes(2).Text
            'CG changed the following line of code to recognize the 1st TextBox
            .Body = ActiveSheet.TextBoxes(1).Text
            'CG changed the following line of code from .Send to .Display temporarily
            .Display
        End With
    Next
End Sub
 

Attachments

  • Capture_email from text box.PNG
    Capture_email from text box.PNG
    24.6 KB · Views: 22

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
change:
.Body = ActiveSheet.TextBoxes(1).Text
to
.Body = ActiveSheet.TextBoxes(1).Text & vbNewLine & MyComplianceSig

if MyComplianceSig is a string with your signature in there.
 
Upvote 0
Hi, thank you for your reply. My email signature will be nowhere on the sheet that I snapped for you.

Is it possible to have the code add the email signature after (or while) the email is being generated?
 
Upvote 0
I can't say I know a way to access your Outlook signature from excel VBA. Could you reproduce it in a string in your excel vba code?
 
Upvote 0
I'll try that right now adding my signature to a string like you ask.. BRB.
I should let you know that different people will be using this template to send emails. They will have different email signatures
 
Upvote 0
Hello, I was out for two days but I'm back now. It did not work.

I've been reading and noticing that many blogs or sites say that having Outlook add the email signature is not possible....Can you let me know if this is possible or not? THanks!!
 
Upvote 0
If Ron de Bruin says it's possible, then Yes it is possible.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top