VBA Email to Recipient based on cell value in workbook

excelisfunusually

New Member
Joined
Jul 29, 2015
Messages
22
Hello!

I am trying to use a macro to send email to a recipient based on the value in a cell (B21 on Sheet 4). This value is the result of a vlookup formula that changes based on another cell's input. My vba code is below. Any help is greatly appreciated!


Sub Send_email_pm()

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim strto As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strbody = "Please check SharePoint for the latest update to this document"

strto = Worksheets("Sheet4").Range("B21").Value

On Error Resume Next
With OutMail
.To = strto
.Subject = Dir(ThisWorkbook.FullName)
.Body = strbody
.Send

End With

End Sub


Thanks!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,225,738
Messages
6,186,725
Members
453,368
Latest member
positivemind

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