Hi Team,
I am trying to use the below VBA Code to generate the outlook Draft report with attachment, however was unable to do so. Please navigate me to the correct coding:
Sub SEND_EMAIL_WITH_FILE()
On Error Resume Next
Sheet6.Activate
Dim Otl As Outlook.Application
Set Otl = New Outlook.Application
Dim otlmail As Outlook.MailItem
Dim i As Long
For i = 15 To Range("A150").End(xlUp).Row
If Cells(i, 6).Value = "yes" Then
Set otlmail = Otl.CreateItem(olMailItem)
With otlmail
.Body = "Hi " & Cells(i, 1).Value _
& vbNewLine & vbNewLine & _
"Please provide the BS Recon for attached global account details for " & Range("B2") & " of " & Range("B1")
.To = Cells(i, 2).Value
.CC = Cells(i, 3).Value
.Subject = Range("B3") & ":" & Cells(i, 4).Value & " BS RECON BACKUP " & Range("B1")
.Attachments.Add Cells(i, 5).Value
.Display
End With
'MsgBox "Selected Item Sent", vbOKOnly
' ElseIf Cells(i, 6).Value = "NO" Then
' MsgBox "Mail Not Required", vbOKOnly
' Exit Sub
End If
Next i
Set Otl = Nothing
Set otlmail = Nothing
MsgBox "DONE", vbOKOnly
'MsgBox "Mail Has Been Sent To Respective Person Along With Files", vbOKOnly
End Sub
FYI - I have accessed all related References.
I am trying to use the below VBA Code to generate the outlook Draft report with attachment, however was unable to do so. Please navigate me to the correct coding:
Sub SEND_EMAIL_WITH_FILE()
On Error Resume Next
Sheet6.Activate
Dim Otl As Outlook.Application
Set Otl = New Outlook.Application
Dim otlmail As Outlook.MailItem
Dim i As Long
For i = 15 To Range("A150").End(xlUp).Row
If Cells(i, 6).Value = "yes" Then
Set otlmail = Otl.CreateItem(olMailItem)
With otlmail
.Body = "Hi " & Cells(i, 1).Value _
& vbNewLine & vbNewLine & _
"Please provide the BS Recon for attached global account details for " & Range("B2") & " of " & Range("B1")
.To = Cells(i, 2).Value
.CC = Cells(i, 3).Value
.Subject = Range("B3") & ":" & Cells(i, 4).Value & " BS RECON BACKUP " & Range("B1")
.Attachments.Add Cells(i, 5).Value
.Display
End With
'MsgBox "Selected Item Sent", vbOKOnly
' ElseIf Cells(i, 6).Value = "NO" Then
' MsgBox "Mail Not Required", vbOKOnly
' Exit Sub
End If
Next i
Set Otl = Nothing
Set otlmail = Nothing
MsgBox "DONE", vbOKOnly
'MsgBox "Mail Has Been Sent To Respective Person Along With Files", vbOKOnly
End Sub
FYI - I have accessed all related References.