Good Afternoon,
With help from people on here and Google I have created VBA to issue an email based on a form that is completed. The VBA runs (stepped through) with no errors but doesnt send anything via Office.
I am using Excel 2016 I think, but I am missing something but I am unsure what it is. The email doesnt need any attachements, just the body of the text to show.
Thanks in advance and the code is below
With help from people on here and Google I have created VBA to issue an email based on a form that is completed. The VBA runs (stepped through) with no errors but doesnt send anything via Office.
I am using Excel 2016 I think, but I am missing something but I am unsure what it is. The email doesnt need any attachements, just the body of the text to show.
Thanks in advance and the code is below
Code:
Sub Email_This()
'Working in Excel 2000-2016
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim MyEmail As String
MyEmail = EmailUpload.TextBox2.Value
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.From = "customerrelationscredit&collections@britishgas.co.uk"
.To = MyEmail
.CC = ""
.BCC = "" 'does this need to be issued to the inbox
.Subject = "Notification of Complaint Assigned to you."
.Body = "Good Morning/Afternoon " & AssignedTo.Value & vbCrLf & _
"" & Chr(10) & _
"Complaint has been assigned to your reference: " & ComplaintNo.Value & vbCrLf & _
"The next review date is " & DueDate.Value & vbCrLf & _
"" & Chr(10) & _
"" & Chr(10) & _
"Please pick up your complaint on receipt of the email to begin your investigations." & vbCrLf & _
"" & Chr(10) & _
"Please remember to add the following to the next contact in your complaint to ensure this is not missed." & vbCrLf & _
"" & Chr(10) & _
"" & Chr(10) & _
"Summary of any advice given actions taken/agreed" & vbCrLf & _
" Vulnerability/Ability to pay:" & vbCrLf & _
" Eligible for Smart meters:" & vbCrLf & _
" Active / Inactive account:" & vbCrLf & _
" All relevant correspondence attached :" & vbCrLf & _
"" & Chr(10) & _
"" & Chr(10) & _
"Please remember if you close your complaint in day you will need to signpost the customer verbally/send leaflet if you forget as the Auto D+1 letter will not go out if it is closed in day." & vbCrLf & _
"" & Chr(10) & _
"Also remember if a complaint has been raised in day and you backdate it to the previous day and close in day, the Auto D+1 letter will not go out, you will need to verbally signpost/send leaflet if you forget." & vbCrLf & _
"" & Chr(10) & _
"Thanks" & Chr(10) & _
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub