floggingmolly
Board Regular
- Joined
- Sep 14, 2019
- Messages
- 167
- Office Version
- 365
- Platform
- Windows
I have a code that sends an email with pdf attachment. I have a dropdown in cell L3 with options Display and Send. Depending on what is chosen I want to either Display or Send the email. I can't seem to get the code to work. Any help would be appreciated. Below is the email section of my code.
Code:
If .Range("K3").Value = "Email" Then
Set OutApp = CreateObject("Outlook.Application") 'Create Outlook Application
Set OutMail = OutApp.CreateItem(0) 'Create Email
With OutMail
.bcc = Sheet1.Range("R" & CustRow).Value & ";" & Sheet1.Range("S" & CustRow).Value & ";" & Sheet1.Range("T" & CustRow).Value
.Subject = "Notification email for " & Sheet1.Range("F" & CustRow).Value
.Body = "DO NOT RESPOND TO THIS EMAIL" & vbCrLf & _
"RESPOND TO THE SPECIALIST ASSIGNED TO YOUR AREA" _
& vbCrLf & "MARY - CENT/EAST, JAME - SOUTH/WEST/MIDA/GULF." _
& vbCrLf & vbCrLf & "This is line 1 of the email" _
& vbCrLf & "This is line 2 of the email" _
& vbCrLf & "This is line 3 of the email" _
& vbCrLf & Sheet1.Range("L" & CustRow).Value & " And here is line 4."
.Attachments.Add FileName
If .Range("L3").Value = "Display" Then
.Display
Else:
.send
End If
End With
Application.Wait (Now + TimeValue("0:00:5"))
Else:
WordDoc.Close False
End If
End If '3 condition met
Next CustRow
WordApp.Quit
End With
End Sub