Results 1 to 1 of 1
  1. #1
    breakingme10 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153

    Exclamation VBA New Email From Template No Longer Working

    I used a template file stored in my PC to create and email message and display it so i could double check all info before sending for the last two years. Now suddenly it doesn't work anymore! I am getting the error saying the object could not be found on the .Display line.


    if i add On Error Resume Next before the with omail then i get no error and if i then open Outlook, the message will be in my Drafts, but will not be in HTML format.
    It worked last year and the year before. The last time I KNOW it worked was 12/28/2018 (just a couple months ago!).
    I did update my office from version 1803 to the newest version 1901.
    I have quadruple checked my attachment and it is generating the correct file path and it is attaching it to the email.
    But the email will not display anymore and is always in plain text. Any help would be greatly appreciated!

    Code:
    Private Sub cmd_EmailInspections_Click()Dim oApp As Outlook.Application
    Dim oMail As Outlook.MailItem
    Dim oAtt As Outlook.Attachment
    Dim mySQL As String
    Dim myTo As String
    Dim myCC As String
    Dim BodyWithoutSignature As Variant
    Dim myAtt As String
    Dim myDivisionInt As Integer
    Dim myDivision As String
    Dim myYear As String
    Dim myDate As String
    Dim myOldName As String
    Dim myNewName As String
    Dim myNewNewName As String
    Dim myNewOldName As String
    
    
    Set oApp = New Outlook.Application
    
    
    myYear = Me.txt_MyYear
    
    
    Select Case myYear
        Case 2018
            Set oMail = oApp.CreateItemFromTemplate("C:\Scripts\Outlook\AnnualInspections2018.oft")
        Case 2017
            Set oMail = oApp.CreateItemFromTemplate("C:\Scripts\Outlook\AnnualInspections2017.oft")
        Case 2019
            Set oMail = oApp.CreateItemFromTemplate("C:\Scripts\Outlook\AnnualInspections2019.oft")
    End Select
    
    
    myTo = Me.txt_Email
    myDivisionInt = DLookup("DivisionID", "tblCustomers", "[PK_Customer] = " & Me.cbo_Customer)
    myDate = Format(Date, "yyyy-mm-dd")
    myDivision = REDACTED INFO
    myCC = REDACTED INFO
    
    
    myAtt = "R:\" & myYear & "\" & myDivision & "\.Complete\" & Me.cbo_Customer.Column(1) & " - Annual Inspections " & myYear & ".zip"
    
    With oMail
        BodyWithoutSignature = .HTMLBody
    End With
    
    With oMail
        .Display
        .To = myTo
        .CC = myCC
        .Recipients.ResolveAll
        .BodyFormat = olFormatHTML
         .Attachments.Add (myAtt)
        .HTMLBody = BodyWithoutSignature
        .Save
    End With
    
    
    
    
    Set oMail = Nothing
    Set oApp = Nothing
    
    END SUB

    Edit: Now it is working but it displays a double signature. The signature in the template is a different signature than my default signature.
    Edit Again: Now Solved, I needed to move .Display immediately under With oMail.
    Last edited by breakingme10; 02-27-2019 at 11:23 AM. Reason: Solved

Please reply to this thread with any new information or opinions.

Similar Threads

  1. NZ Function no longer working.
    By ArthurHarveyJr in forum Access
    Replies: 12
    Last Post: 02-11-2019, 04:37 AM
  2. report no longer working
    By chriswrcg in forum Reports
    Replies: 8
    Last Post: 01-22-2019, 05:13 PM
  3. Form no longer working
    By ceatana in forum Forms
    Replies: 3
    Last Post: 05-22-2018, 12:55 PM
  4. Email from Access no longer working
    By Gina Maylone in forum Access
    Replies: 4
    Last Post: 10-12-2016, 06:46 AM
  5. Replies: 3
    Last Post: 08-17-2016, 08:26 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums