Email VBA pull email address from cell

BadFish523

Board Regular
Joined
Feb 15, 2018
Messages
56
Hello all,

I have this simple VBA to send the sheet as an email when a button is pressed.

Sub MailTest()
ActiveWorkbook.SendMail "email@email.com", "Leader Standard Work for previous week " & Date


End Sub

How would I change this to pull the email address from cell A10 on tab "Directions"?
I'm trying to make the sheet simpler for people to adjust who they want to email I to?

Thanks!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
.
Try :

Code:
Option Explicit


Sub MailTest()
    ActiveWorkbook.SendMail Sheets("Directions").Range("A10").Value, "Leader Standard Work for previous week " & Date
End Sub
 
Upvote 0
The following code is designed to pull from an email list created in Column A.

Note: the .Subject and .Body of the email must be changed to the verbiage you desire.

Code:
Option Explicit
-------------------------------------
Private Sub cmdTestEmail_Click()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim strCC As String
     
    Dim cell As Range
     
    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")
    'OutApp.Session.Logon
     
    On Error GoTo cleanup
   For Each cell In ActiveWorkbook.Worksheets("Directions").Columns("A").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" Then
             
            If OutMail Is Nothing Then
                Set OutMail = OutApp.CreateItem(0)
                With OutMail
                    .To = cell.Value
                    .Subject = "CHANGE SUBJECT"
                    .Body = "Enter your Text here"
                     'You can add files also like this
                     '.Attachments.Add ("C:\test.txt")
                    .Display 'Or use Send
                End With
            Else
                On Error Resume Next
                strCC = strCC & cell.Value & ";"
                On Error GoTo 0
                 
            End If
             
        End If
    Next cell
    OutMail.BCC = Left(strCC, Len(strCC) - 1)
     
cleanup:
    Set OutMail = Nothing
    Set OutApp = Nothing
    Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,170
Members
448,870
Latest member
max_pedreira

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