Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Dear all,

I currently have this VBA code (please note the part highlighted in bold):

VBA Code:
Option Explicit

Private Const FilePath As String = "\\COMPANY.SSSS.COMPANY.NET\userdata\t5382304\home\Documents\TEST folder\"
Sub send_email_complete()
Dim OutApp As Object
    Dim OutMail As Object
    Dim i As Long
    Dim ws As Worksheet
   
    '~~> Change this to the relevant worksheet
    '~~> that has the emails (right now Sheet1 has it)
    Set ws = ThisWorkbook.Sheets("Sheet1")

    Set OutApp = CreateObject("Outlook.Application")
   
    '~~> Looping from rows 2 to 10 (update if necessary)
    For i = 2 To 10
        '~~> This creates a new email (so we can send out multiple emails)
        Set OutMail = OutApp.CreateItem(0)

With OutMail
.To = ws.Cells(i, 15).Value2
.BCC = ws.Cells(i, 16).Value2
[B].Subject = "Files for Everyone"[/B]
.HTMLBody = "Dear all,<br/>" & "<BR>" & _
"bunch of text that does not matter for this question" & "<BR>"
.Attachments.Add FilePath & ws.Cells(2, 17).Value2

.Display

End With
Next i

End Sub

This is linked to the following Excel sheet:

1643117416581.png


My question is, is there some way to code the SUBJECT in the email coding, so it says Greetings Dear (Entity Name), so for example it would say in the subject for nr. 1: "Greetings Dear Pentagon".

I have the entities currently in the range N2:N10, but I expect to have somewhere around N2:N150 for my actual version.

Would truly appreciate some assistance here!!

Thank you all! :)

Kind regards,
Jyggalag
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Code:
.Subject = "Greetings Dear " & ws.Cells(i, "N").value

should do it.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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