Hello mjwillyone,
Here is macro customized to your needs. The name is column "A", the emial address in column "B", and the amount in column "C". The subject line includes the salutation and the amount. You can make changes to to starting row and the columns if you need to. I have highlighted them in red.
Private Declare Function ShellExecute _
Lib "Shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEmails()
Dim Msg As String
Dim R As Long
Dim RetVal As Long
Dim Subj As String
Dim URL As String
StartRow = 1
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
LastRow = IIf(LastRow < StartRow, StartRow, LastRow)
For R = StartRow To LastRow
Subj = "Dear " & Cells(R, "A").Text & ", I wanted to let you know that you will receive " & Cells(R, "C").Text
URL = "MailTo:" & Cells(R, "B").Text & "?subject=" & Subj
RetVal = ShellExecute(0&, "open", URL, vbNullString, vbNullStirng, 0&)
'Did Connection Fail? Errors are from 0 to 32
If RetVal <= 32 Then
Select Case RetVal
Case 2 'SE_ERR_FNF
Msg = "File not found"
Case 3 'SE_ERR_PNF
Msg = "Path not found"
Case 5 'SE_ERR_ACCESSDENIED
Msg = "Access denied"
Case 8 'SE_ERR_OOM
Msg = "Out of memory"
Case 32 'SE_ERR_DLLNOTFOUND
Msg = "DLL not found"
Case 26 'SE_ERR_SHARE
Msg = "A sharing violation occurred"
Case 27 'SE_ERR_ASSOCINCOMPLETE
Msg = "Incomplete or invalid file association"
Case 28 'SE_ERR_DDETIMEOUT
Msg = "DDE Time out"
Case 29 'SE_ERR_DDEFAIL
Msg = "DDE transaction failed"
Case 30 'SE_ERR_DDEBUSY
Msg = "DDE busy"
Case 31 'SE_ERR_NOASSOC
Msg = "Default Email not configured"
Case 11 'ERROR_BAD_FORMAT
Msg = "Invalid EXE file or error in EXE image"
Case Else
Msg = "Unknown error"
End Select
Msg = "Unable to Send Email to " & vbCrLf & "'" & MailTo & "'" & vbCrLf _
& vbCrLf & "Error Number " & CStr(RetVal) & vbCrLf _
& Msg
RetVal = MsgBox(Msg, vbExclamation + vbOKOnly)
End If
Next R
End Sub
Adding the Macro
1. Copy the macro above pressing the keys CTRL+C
2. Open your workbook
3. Press the keys ALT+F11 to open the Visual Basic Editor
4. Press the keys ALT+I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL+V
7. Make any custom changes to the macro if needed at this time
8. Save the Macro by pressing the keys CTRL+S
9. Press the keys ALT+Q to exit the Editor, and return to Excel.
To Run the Macro...
To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
Sincerely,
Leith Ross
Bookmarks