Excel VBA email

NVRensburg

Board Regular
Joined
Jul 1, 2014
Messages
113
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi there

I have a long VBA to send emails based on a sheet. It works perfectly however I just need help modifying this part to add in the persons name from cell B2 after where is says .Body = "Good day," & vbLf & vbLf _
So the email will say Hi Jake with B2 showing the name Jake


' Prepare e-mail with PDF attachment
With OutlApp.CreateItem(0)

' Prepare e-mail
.Subject = Range("$C$2")
.To = Range("$C$3")
.Body = "Good day," & vbLf & vbLf _
& " " & vbLf _
& "Please find attached the latest version of the Workforce Planner." & vbLf & vbLf _
& "Should there be any changes from your side, or if something is incorrect, please reply to this email with the required changes so that I can edit the worksheet from my side." & vbLf _
& " " & vbLf & vbLf
.Attachments.Add PdfFile
.SentOnBehalfOfName = "abc@company.com"
' Try to send
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
See addition in red below?
Rich (BB code):
  ' Prepare e-mail with PDF attachment
  With OutlApp.CreateItem(0)
 
    ' Prepare e-mail
    .Subject = Range("$C$2")
    .To = Range("$C$3")
    .Body = "Good day," & vbLf & vbLf _
          & "Hi " & Range("B2") & vbLf _
          & "Please find attached the latest version of the  Workforce Planner." & vbLf & vbLf _
          & "Should there be any changes from your side, or if something is incorrect, please reply to this email with the required changes so that I can edit the worksheet from my side." & vbLf _
               & " " & vbLf & vbLf
    .Attachments.Add PdfFile
   .SentOnBehalfOfName = "abc@company.com"
    ' Try to send
 
Upvote 0
See addition in red below?
Rich (BB code):
  ' Prepare e-mail with PDF attachment
  With OutlApp.CreateItem(0)
 
    ' Prepare e-mail
    .Subject = Range("$C$2")
    .To = Range("$C$3")
    .Body = "Good day," & vbLf & vbLf _
          & "Hi " & Range("B2") & vbLf _
          & "Please find attached the latest version of the  Workforce Planner." & vbLf & vbLf _
          & "Should there be any changes from your side, or if something is incorrect, please reply to this email with the required changes so that I can edit the worksheet from my side." & vbLf _
               & " " & vbLf & vbLf
    .Attachments.Add PdfFile
   .SentOnBehalfOfName = "abc@company.com"
    ' Try to send
Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,210
Members
453,023
Latest member
alabaz

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