VBA for mass email with signature

muhleebbin

Active Member
Joined
Sep 30, 2017
Messages
252
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hi Everyone,

I found this thread regarding this solution however was wondering if it could be applied to the code that I currently have:

VBA Code:
Sub SendEmail(what_address As String, subject_line As String, mail_body As String)
'
' SendEmail Macro
'

Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")

    Dim olMail As Outlook.MailItem
    Set olMail = olApp.CreateItem(olmailitem)
  
    olMail.Display
    olMail.To = what_address
    olMail.Subject = subject_line
    olMail.HTMLBody = mail_body
    olMail.Send

   

End Sub
Sub SendMassEmail()

row_number = Sheet4.Range("L2")

Do
DoEvents
  row_number = row_number + 1
  Dim mail_body_message As String
  Dim full_name As String
  Dim location_name As String
    
  mail_body_message = Sheet4.Range("D2")
  full_name = Sheet4.Range("A" & row_number)
  
  mail_body_message = Replace(mail_body_message, "replace_name_here", full_name)
    
  Call SendEmail(Sheet4.Range("B" & row_number), "Email Subject", mail_body_message)
Loop Until row_number = Sheet4.Range("L3")
  
End Sub

I prefer this code as it could be modified to add fields to personalize the email, though it seems the mail_body_message overrides the signature in the other solution.

Any assistance would be greatly appreciated!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
if you are looking to add the standard outgoing message signature then try changing this
Excel Formula:
olMail.Display
olMail.To = what_address
olMail.Subject = subject_line
olMail.HTMLBody = mail_body
olMail.Send

to this

Excel Formula:
olMail.Display
signature=omail .htmlbody
olMail.To = what_address
olMail.Subject = subject_line
olMail.HTMLBody = mail_body & signature
olMail.Send
 
Upvote 0
Solution
Thank you very much gordsky! That absolutely worked!

Is there any way to get rid of the line
olMail.Display

When I tried it, it reverted back to just the body without signature. I figure it gets annoying when I need to send 100+ emails to actually have it display each one.
 
Upvote 0
Thank you very much gordsky! That absolutely worked!

Is there any way to get rid of the line
olMail.Display

When I tried it, it reverted back to just the body without signature. I figure it gets annoying when I need to send 100+ emails to actually have it display each one.
unfortunately not, that is how it captures the outgoing signature
if this has solved your query please mark as resolved
 
Upvote 0
That sadly makes sense. Thanks for your help here!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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