Sub SendEmail()
If MsgBox("Note01: Have you opened Outlook app?", vbYesNo) = vbNo Then Exit Sub
Dim OutlookApp As Object
Dim OutlookMailItem As Object
Dim strEmail As String
Dim wbkS As Workbook
Dim wshS As Worksheet
Dim FilePicker As fileDialog
Dim mypath As String
Set FilePicker = Application.fileDialog(msoFileDialogFilePicker)
With FilePicker
.Title = "Please Choose One"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Custom Excel Files", "*.xlsx, *.csv, *.xls"
.ButtonName = "Confirm"
If .Show = -1 Then
mypath = .SelectedItems(1)
Else
End
End If
End With
'On Error Resume Next
Set wbkS = Workbooks.Open(mypath)
Set wshS = wbkS.Worksheets(1)
Set OutlookApp = CreateObject("Outlook.application")
Set OutlookMailItem = OutlookApp.CreateItem(0)
With OutlookMailItem
strEmail = wshS.Range("Q4").Value
.To = strEmail
.Subject = wshS.Range("J11").Value
.Body = wshS.Range("R4").Value
.send
End With
wbkS.Close
MsgBox "Email has been sent to: " & strEmail
Set OutlookMailItem = Nothing
Set OutlookApp = Nothing
Set FilePicker = Nothing
Set wbkS = Nothing
Set wshS = Nothing
End Sub
Sub SendEmail()
'If MsgBox("Note01: Have you opened Outlook app?", vbYesNo) = vbNo Then Exit Sub
Dim OutlookApp As Object
Dim OutlookMailItem As Object
Dim strEmail As String
Dim wbkS As Workbook
Dim wshS As Worksheet
Dim FilePicker As fileDialog
Dim mypath As String
Set FilePicker = Application.fileDialog(msoFileDialogFilePicker)
With FilePicker
.Title = "Please Choose One"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Custom Excel Files", "*.xlsx, *.csv, *.xls"
.ButtonName = "Confirm"
If .Show = -1 Then
mypath = .SelectedItems(1)
Else
End
End If
End With
'On Error Resume Next
Set wbkS = Workbooks.Open(mypath)
Set wshS = wbkS.Worksheets(1)
Set OutlookApp = CreateObject("Outlook.application")
Set OutlookMailItem = OutlookApp.CreateItem(0)
With OutlookMailItem
strEmail = wshS.Range("Q4").Value
.To = strEmail
.Subject = wshS.Range("J11").Value
.Body = wshS.Range("R4").Value
.send
End With
wbkS.Close
MsgBox "Email has been sent to: " & strEmail
Set OutlookMailItem = Nothing
Set OutlookApp = Nothing
Set FilePicker = Nothing
Set wbkS = Nothing
Set wshS = Nothing
End Sub