VBA working to send an email, doesnt error but doesnt send

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
769
Office Version
  1. 365
Platform
  1. Windows
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

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
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
no errors because you turned off error routines with "On Error Resume Next"
Build an error trap:

Code:
'1st line of code should be
on Error goto ErrTrap

'**** your code here

exit sub
ErrTrap:
msgbox Err.description,,err
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top